Jack Christensen <jack / jncsoftware.com> writes:

> Just got bit by a little order of operations confusion.
>
> irb(main):012:0> a = nil or 1
> => 1
> irb(main):013:0> a
> => nil
> irb(main):014:0> a = (nil or 1)
> => 1
> irb(main):015:0> a
> => 1
>
> Probably old news to long time rubyists but it surprised me. Is there
> any way to get a warning or something when a statement like the above
> may not be behaving like you would think?
>
> Jack

Not that I know of, but note that "||" is like "or" with different
precedence:

irb(main):001:0> a = nil || 1
=> 1
irb(main):002:0> a
=> 1

-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org