2009/1/27 Brian Candler <b.candler / pobox.com>:
> Robert Klemme wrote:
>> is_between = now > yesterday and now < tomorrow
>
> Danger danger!!!
>
> irb(main):012:0> foo = 3 > 1 and 3 < 2
> => false
> irb(main):013:0> foo
> => true
>
> 'and' and 'or' have lower precedence even than '=', so it's parsed as
>
>  (foo = 3 > 1) and (3 < 2)
>
> The moral is: don't use these very-low precedence operators unless you
> really know what you're doing. And even then, use parentheses to be
> sure. Learned the hard way :-)

Thanks for the heads up! Originally I did not have the "and" version
in because I usually use the "&&" just because of the precedence issue
you mention.  Somehow reading the other "and" version tricked my into
believing it would be safe here.

Mantra of the day: Always test!  Always test! Always test! :-)

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end