On 15.11.2009 19:28, Seebs wrote:
> On 2009-11-15, 7stud -- <bbxx789_05ss / yahoo.com> 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

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/