M
Mauricio Fernandez
well, i was thinking of combining Mr. Haines idea with Mr. James to
get #store_new, which seemed just about right. but now your suggestion
is quite interesting. at first i wasn't so sure, but thinking about it
a little more it makes sense -- "is something stored with this key? if
not store this value with it". i was also worried that it did not
return the stored value like the normal store, but i realize now that
could be ambigious if value=nil, so you may be on point. is that right?
Yes, that's the idea ("more regular behavior"), but as Robert said, a
predicate method with side-effects seems _very_ dangerous (yes, store!? would
be more accurate
So it might make sense to name it e.g. #store_once, with the above
semantics. Returning the value that was passed to the method makes little
sense: it doesn't provide any information we didn't have to being with.