Yukihiro Matsumoto
11/28/2007 4:37:00 AM
Hi,
In message "Re: Binary Logic, Bug or Feature?"
on Wed, 28 Nov 2007 13:33:36 +0900, "Malcolm Lockyer" <maxpenguin@gmail.com> writes:
|I have been pulling my hair out for the last 20 minutes trying to find
|out what is wrong in my app that has some pretty basic binary logic.
|Here is a concise example in an irb session that shows my problem
|(certainly, what I was working on wasn't nearly as simple the sides of
|AND were variables etc.):
|
|?> x = true and true
|=> true
|>> x
|=> true
|
|(this is what I expect, true and true = true)
|
|>> x = true and false
|=> false
|>> x
|=> true
|
|But what I've got here is "true and false" == false, but it assigns
|true to x. So true and false == false, but really == true... Have I
|lost my mind, should it do this? Does it do it for anyone else? It
|seems weird to me since the first example does what I expect, but the
|second doesn't...
Precedence.
x = true and false
is parsed as
(x = true) and false
not
x = (true and false)
matz.