From: Chris Hulan Date: 2010-03-20T21:40:32+09:00 Subject: Re: Question about the evaluation of x = 'foo' if false On Mar 17, 12:01 pm, Aníbal Rojas wrote: > Hello, > >    I am kind of lost with the nil result while I am expecting a false: > > irb(main):001:0>  x = 'foo' if false > => nil > irb(main):002:0> x > => nil > irb(main):003:0>  x = 'foo' if true > => "foo" > irb(main):004:0> x > => "foo" > >    Thanks in advance for sharing your knowledge, > > -- > Anìbal Rojas See http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html#UH 'if' doesn't return the logical value it evaluates, it returns the value of the last statement executed, in the false case nothing is executed, and nil is Ruby's nothing value Cheers