Why can't I use "or" here?

On Thu, Dec 31, 2009 at 3:13 PM, Jeff P. [email protected] wrote:

I know Perl, but I’m still surprised.

perl -le ‘print undef or 4’

perl -le ‘print(undef or 4)’

4

do not be surprise, ruby opted for the former case since it is more
common, and therefore has relegated the “or/and” ops w very low
precedence level (and ergo different fr their sibling ops “||/&&”)

in other words, if you see a method like

puts 1,2 or 4
1
2
=> 4

it actually means

puts( 1,2) or 4
1
2
=> 4

and if you write a statement like

puts( 1,2 or 4)

ruby will err for you
but friendly enough to allow you to by (re)emphasizing…

so maybe you meant

puts( 1, (2 or 4))

best regards
-botp