On Apr 20, 2006, at 1:51, John Johnson wrote:

> I was wondering today, so I tried this:
>
> puts "It's true" if 0
>
> Which prints "It's true", meaning 0 is not false. (This should  
> surprise C/C++/etc. people).
>
> So that means
> puts "It's equal" if 0 == true

You are seeing a particular case of the fact that the boolean  
interpretation an object may be different from the object value  
itself. And == is comparing object values, not boolean  
interpretations. Then the result of == is interpreted in boolean  
context, but by then 0 was seen as an integer already, which is  
certainly different from the object true.

To make it apparent take "foo". The string "foo" is true in boolean  
context, but it won't surprise you to realise that "foo" == true does  
not hold.

-- fxn