From: bbiker Date: 2007-04-20T12:50:21+09:00 Subject: Re: Unless Expression Parsing On Apr 19, 9:53 pm, Gary Wright wrote: > I just came across an unexpected parsing problem: > > x = 3 unless true # parses just fine, x = nil > > p(3 unless true) # parser chokes on unless > > p((3 unless true)) # OK, 'nil' is printed > > This seems like a bug in the parser rather than a real > syntax problem, but maybe I'm missing something? > > Gary Wright in irb: x = 3 unless true => nil x => nil # x declared as a nil object since it was never assigned an object p 3 unless true => nil p (( 3 unless true)) => nil # you're asking for the result of '3 unless true', ) p nil => # no result since p did nothing 3 unless true => # the result is nil but not captured so p (3 unless true) => # no result since you are asking p to print nothing Note: the above is equivalent to unless true so 'p 3' never gets interpreted and nothing happens p 3 end