From: Robert Dober Date: 2007-01-09T19:06:03+09:00 Subject: Re: a most undangerous Hash#store! ------=_Part_39817_27912791.1168337161014 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/9/07, Trans wrote: > > > Mauricio Fernandez wrote: > > > Anyway, Trans was talking about destructive updates, so what about > > > > def store?(key, value) > > unless key?(key) > > store(key,value) > > return true > > end > > false > > end > > > > similar to the #store! he described, but with a more regular behavior > when you > > have nil/false values... > > 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? > if so then i have to go with your suggestion. > > t. > > > Please reconsider making an updating predicate Tom! (no pun intended) I was not joking above I *really* feel that is a very bad idea. Your semantic interpretation of "?" makes sense but only without consideration of the context of what all other "?" methods do. Cheers Robert -- "The best way to predict the future is to invent it." - Alan Kay ------=_Part_39817_27912791.1168337161014--