From: Robert Klemme Date: 2007-09-07T22:24:21+09:00 Subject: Re: assigning to hash keys when there is a default value? 2007/9/7, dblack@wobblini.net : > > I believe it's not the only case. Although x= and []= are different, it > > seems in *both* cases assignment is not even invoked for ||=: > > True, but by "only *such* case" I meant: only case where evaluating > the lhs and getting true doesn't tell the whole story, in terms of the > functionality of the object, because of the defaulting to a value in > the absence of a key. Ah, ok. Should've read more carefully. I am sorry. > I suppose one could argue that it isn't ||='s problem if the lhs is > actually a kind of proxy. Nothing has yet convinced me, though, that > ||= should not behave like x = x || y, even if the actual assignment > gets optimized away. Umm, now I am confused. I thought the "optimized away" bit is the critical bit - if you allow for this difference then they do actually behave the same, don't they? Btw, here's a possible explanation why the behavior is the way it is: []= and x= are usually costly operations (i.e. not just assignments but methods doing some work) so avoiding that would help overall performance. Still I believe that's probably better than the consistency although I usually tend to favor consistency as well. Kind regards robert