From: Rob Biedenharn Date: 2009-01-10T08:31:18+09:00 Subject: Re: value of an expression? On Jan 9, 2009, at 5:57 PM, Kedar Mhaswade wrote: >> It is the equivalent of: >> >> if (1 + 1 != 2) >> s = "surprising" >> end >> >> So s = "surprising" is never evaluated, and s continues to equal >> "test". > > Ah ok, thanks. However, I was thinking if it should be nil, not > "surprising", because of the following experience with irb: > >>> "surprising" if (1+1 !=2) > => nil > > which gives an impression that the value of this entire expression is > nil. > > -Kedar irb is showing the #inspect of the last expression that it evaluates. It evaluates (1+1!=2) finds that to be false and 'if false' means that "nothing" is returned by the expression on the left ("surprising"). That nothing is just nil. You could convince yourself of this by running: irb> if 1+1 != 2 irb> "surprising" irb> end => nil -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com