[rules-users] Boolean logic fail?

Matthew Runo mruno at zappos.com
Fri Jun 4 19:23:15 EDT 2010


Hello folks -

We noticed something weird today, and was hopeing that someone here might be able to explain it for us a bit.. Here's the rule we had:

eval( -1 < 0 or
8 > 1 or
182 < 0 or
0 == 0);

This was failing, but doesn't it seem like it should work? To get it to work, we tried this:

eval( (-1 < 0) or
(8 > 1) or
(182 < 0) or
(0 == 0));

... but that didn't compile. We then tried this (and it worked!):

eval( (-1 < 0) ||
(8 > 1) ||
(182 < 0) ||
(0 == 0));

So, my question is simply - why? What's the difference between "or" and || - and when should we use them?

Thanks for your time!

Matthew Runo
Software Engineer, Zappos.com
mruno at zappos.com - 702-943-7833





More information about the rules-users mailing list