From: Steve Wilhelm Date: 2009-11-16T11:26:05+09:00 Subject: Re: very newbie question This as well as many other unique features of Ruby are covered very clearly in 'The Ruby Programming Language' by Flanagan and Matsumoto. I would recommend getting a copy and reading it. - Steve W. Robert Klemme wrote: > On 15.11.2009 19:28, Seebs wrote: >> On 2009-11-15, 7stud -- wrote: >>> Whoops. I misinterpreted what your issue was. Yes, ruby is strange >>> that way. In ruby, only nil evaluates to false (and of course false IS >>> false). As a result, everything but nil and false evaluates to >>> true--including 0. >> >> Lua's the same way. >> >> I'm not comfortable with it yet, since I'm from a C background, but I >> think it's logically preferable. > > I think initially I found it irritating, too. But that was just for a > very short period. Nowadays I believe you hit the nail on the head: > it's logically preferable. Often, code that looks up something in a > Hash or other data structure will return nil if nothing is found. If > you have numbers in there, code will get more complicated if also 0 can > be stored , you want a 0 returned to be evaluated as a "hit" and the > language would evaluate 0 as false in a boolean context. > > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.