From: Eleanor McHugh Date: 2009-05-06T19:45:18+09:00 Subject: Re: '=||' On 6 May 2009, at 02:38, 7stud -- wrote: > Why do I need to care about what's going on under the hood? Because when things don't work the way you expect, looking under the hood allows you to adjust your expectations ;) > If two > things > produce different results, then how can one be considered syntactic > sugar for the other. In my opinion, "syntactic sugar" means that the > two formats can > be used interchangeably--with experienced programmers naturally > gravitating to the shorter, easier to type format, and inexperienced > programmers preferring the longer, but easier to understand format. All that syntactic sugar means is that one phrase is equivalent to another syntactically, not that they're semantically equivalent. However in the case of 'x = x || y' and 'x[n] = x[n] || y' are they even syntactically equivalent? No. They appear syntactically similar, but one invokes the '=' assignment operator whereas the other sends the '[]=' message to the receiver. And because '[]=' leaves the semantics of assignment to the receiver, that allows for the differences you're seeing in this case. Ellie Eleanor McHugh Games With Brains http://slides.games-with-brains.net ---- raise ArgumentError unless @reality.responds_to? :reason