Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Precedence for Idiots

by hippo (Bishop)
on Mar 15, 2020 at 17:03 UTC ( #11114300=note: print w/replies, xml ) Need Help??

in reply to Precedence for Idiots

The penultimate row of the table in the "Logical Questions" section seems incorrect to me.

$ perl -E '$x = 1 == 2 && 3; say $x;' $

This is what I would expect since 1 == 2 is clearly false so $x is false and the right hand side of the && is never evaluated. Perhaps you meant this instead:

$ perl -E '$x = 2 == 2 && 3; say $x;' 3 $

Now the first term is clearly true and the second term evaluates to 3 as intended.

Replies are listed 'Best First'.
Re^2: Precedence for Idiots
by soonix (Canon) on Mar 15, 2020 at 17:29 UTC
    More probably Melly just confounded the last two results…
Re^2: Precedence for Idiots
by rsFalse (Chaplain) on Mar 05, 2021 at 11:39 UTC
    For me "Logical Questions" section's table seems much confusing!
    Column "Meaning" doesn't really mean what is written in column "Function".
    E.g. look at the first example line. Operator 'or' has even higher precedence than '=' and meaning becomes not '($x = (5 == 6)) or ($x = (5 == 5))' but '($x = (5 == 6)) or (5 == 5)', i.e. right side of 'or' operator are not ever assigned to '$x';

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114300]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2022-10-01 14:47 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (126 votes). Check out past polls.