From: Mauricio Fernandez Date: 2007-01-13T21:14:13+09:00 Subject: Re: a most undangerous Hash#store! On Fri, Jan 12, 2007 at 11:15:08AM +0900, Trans wrote: > Mauricio Fernandez wrote: > > 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. > > i agree. i will use that semantic but with a different name. after > further consideration I thought of: > > insert(key,value) > > i think its apt. argree? The problem with that name is that there's no indication of the "just once" semantics, is there? Instead, it makes one think of String#insert and Array#insert, and wonder what #insert translates to in an unordered container (for instance, one interpretation would be that the value will be pushed/unshifted to the array associated to the key, assuming that the hash holds arrays/sets). So it adds to the list of things we have to memorize. Do you feel that store_{once,new,unique} is too long? (I have a slight preference for "once"; "unique" seems a bit puzzling since it seems to refer to the key, which is always unique) -- Mauricio Fernandez - http://eigenclass.org - singular Ruby