From: Einar Karttunen Date: 2002-04-05T15:46:13+09:00 Subject: Re: True equality? On 05.04 15:33, james@rubyxml.com wrote: > This one-liner prints "true": > ruby -e "p 'true' if 1 " > But this does not: > ruby -e "p 'true' if 1 == true" > nor this: > ruby -e "p 'true' if true == 1" > In if statements the values false and nil are false, and all other values are true. In the first case is clearly true by the above definition. The second and third case first evaluate the == expression and then apply if to the result. Now because 1==true => false, and true==1 =>false the if statement is clearly not executed. == means equality at the object level and is usually overridden. It should return true iff both arguments are the same object. - Einar Karttunen