Why can't I use "or" here?

B

botp

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
1
2
=> 4

it actually means
1
2
=> 4

and if you write a statement like

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

so maybe you meant


best regards
-botp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,428
Latest member
RosalieQui

Latest Threads

Top