Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^5: Conditional Operator Confusion

by ikegami (Pope)
on Nov 30, 2006 at 17:12 UTC ( #587014=note: print w/ replies, xml ) Need Help??

in reply to Re^4: Conditional Operator Confusion
in thread Conditional Operator Confusion

The conditional operator has higher precedence than the assignment operator, so
is the same as

The addition operator has higher precedence than the conditional operator, so
is the same as

If you want to do assignments, use if or add parens. Think of as the conditional operator as an operator that returns something.

Comment on Re^5: Conditional Operator Confusion
Select or Download Code
Re^6: Conditional Operator Confusion
by Melly (Hermit) on Nov 30, 2006 at 17:25 UTC

    Thanks - I think I've finally got it (with some help from the chatterbox as well).

    All of which goes to confirm something a coworker once told me..

    Me: What's the precedence in <lang> for these operators?
    CW: Who cares? Use brackets - it's easier to read and
        you won't get screwed...
    Tom Melly,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2015-07-06 06:09 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (70 votes), past polls