From: Stefano Crocco Date: 2009-11-15T17:57:34+09:00 Subject: Re: very newbie question On Sunday 15 November 2009, duxieweb wrote: > |Hello, > | > |I run these in irb: > | > |irb(main):001:0> queue=0 > |=> 0 > |irb(main):002:0> if !queue then print "The queue is empty." end > |=> nil > | > |why the result is nil? > |I thought it should be printing "The queue is empty." > | > |Thanks. > | 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. I hope this helps Stefano