From: Marnen Laibow-Koser Date: 2009-11-16T01:00:16+09:00 Subject: Re: very newbie question duxieweb wrote: > 2009/11/15 Stefano Crocco : > >> >> Because 0 is a true value in ruby, so !queue is false and the body of the if >> expression is not executed. In ruby, the only false values are false and nil. >> > > Oh, that sounds so different from other languages that 0 is a true > value. > > python: >>>> x=0 >>>> if (not x): > ... print "x is false" > ... > x is false > > perl: > # perl -le '$x=0; print "x is false" if not $x' > x is false > Perl has the additional complication that certain math operations will return the string "0 but true", which is transparently converted to 0 in a numeric context but still evaluates to true. So does 0.0, IIRC. > > Thank you. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.