i = true and false in Ruby is true?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-05-10T12:18:31Z Indexed on 2010/05/10 12:24 UTC
Read the original article Hit count: 175

Filed under:

Am I fundamentally misunderstanding Ruby here? I've been writing Ruby code for about 2 years now and just today stumbled on this...

ruby-1.8.7-p249 > i = true and false
 => false 
ruby-1.8.7-p249 > i
 => true 

Could somebody explain what's going on here please? I'm sure it's to spec, but it just seems counter intuitive to me...

© Stack Overflow or respective owner

Related posts about ruby