From: Stefano Mioli Date: 2011-03-22T00:36:05+09:00 Subject: Re: Logical OR in Ruby On 21/03/2011 5.09, Paul Sholtz wrote: > I'm looking at some source code, to try and understand it. [snip] > What I think this code means, is that the value that will be assigned to > "weight" will be either (a) "weight" (if weight has already been > assigned) or else (b) if "weight" is presently nil, then the value 100 > will be assigned to "weight" instead. > > Is this correct? Yep, as others told you. It might be worth pointing out, though, that Ruby might have a different idea of falsehood compared to other languages you might be used to: irb(main):001:0> puts "hey" if 0 hey => nil irb(main):002:0> puts "hey" if [] hey => nil In Python 0 and [] would both evaluate to False. -- Stefano