M
Malcolm Lockyer
Hi Guys,
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=> true
(this is what I expect, true and true = true)
=> 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...
So now I'm reduced to doing something like:
if (true and false) then x = true else x = false end
which is kind of annoying, and not very ruby-esque IMO.
Any advice appreciated!
$ ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]
OS is Ubuntu 7.04.
(I know, old ruby ver - its just the stock ubuntu one)
THANKS!
- Malcolm.
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=> true
(this is what I expect, true and true = true)
=> 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...
So now I'm reduced to doing something like:
if (true and false) then x = true else x = false end
which is kind of annoying, and not very ruby-esque IMO.
Any advice appreciated!
$ ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]
OS is Ubuntu 7.04.
(I know, old ruby ver - its just the stock ubuntu one)
THANKS!
- Malcolm.