From: Ryan Leavengood Date: 2001-10-30T08:22:56+09:00 Subject: [ruby-talk:23778] RE: why is true and false = true ? It's all about precedence. && binds before = which binds before and. See page 221 in the Pickaxe book. So to clarify with parenthesis: tf = true && false is equivalent to tf = (true && false) while: tf = true and false is equivalent to (tf = true) and false I got a warning (assignment in conditional) when I ran that code which clued me in immediately to what the problem was. Ryan Leavengood > -----Original Message----- > From: Phil Tomson [mailto:ptkwt@shell1.aracnet.com] > Sent: Monday, October 29, 2001 6:11 PM > To: ruby-talk ML; undisclosed-recipients: > Subject: [ruby-talk:23772] why is true and false = true ? > > Bizarre, here's the code: > > tf = true && false > puts "true && false = #{tf}" > tf = true and false > puts "true and false = #{tf}" > > Prints: > true && false = false > true and false = true > > Not what I would expect... > Seems like a bug to me. > > I'm running: > ruby 1.6.5 (2001-09-19) [i586-linux] > > Phil