From: Stefano Crocco Date: 2008-04-06T01:04:50+09:00 Subject: Re: The ||= assignment operator On Saturday 05 April 2008, Brian Adkins wrote: > On Apr 5, 8:40 am, "David A. Black" wrote: > > Hi -- > > > > On Sat, 5 Apr 2008, Robert Dober wrote: > > > Furthermore things are simple > > > > > > (1) lval ||= rval is lval = lval || rval > > > > I think you mean: > > > > lval || lval = rval > > Huh? > > My understanding has always been that x ||= y is shorthand for x = x > > || y just as x += y is shorthand for x = x + y. That also seems to be > > the understanding of the "Programming Ruby" text (p. 125 of the > latest). In other words, an assignment will take place even if it's > superfluous. I also thought so, but, according to "The ruby programming language", it's an exception. It states that, if the left hand of var ||= something is not nil or false, no assignment is performed and, if the left hand is an array element or attribute, the setter method is not called. Stefano+