Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Operator Associative in Perl

by JavaFan (Canon)
on Jun 03, 2009 at 12:59 UTC ( #767995=note: print w/replies, xml ) Need Help??


in reply to Operator Associative in Perl

Basically what you are saying is, "give me the value of $a, increment it sometimes afterwards", "give me the value of $a, decrement it sometimes afterwards", "give me the value of $a but only after you've incremented it", "give me the value of $a, but only after you've decremented it". Note that you never say at which moment the value of $a needs to change, just that it needs changing sometime before (or after) fetching the value.

Getting 56555 is not unreasonable. But another result wouldn't have been unreasonable either. In general, it's a bad idea to use ++ or -- twice on the same variable in the same statement is a bad idea. Or to assign to a variable in the same statement as you apply ++ or -- to that variable.

Replies are listed 'Best First'.
Re^2: Operator Associative in Perl
by catellus (Initiate) on Jun 04, 2009 at 17:24 UTC
    JavaFan said:
    >In general, it's a bad idea to use ++ or -- twice on the >same variable in the same statement is a bad idea.

    The paralell of the repitition in the sentence to the original topic gave me quite a chuckle. I hope it was intentional.

      It wasn't intentional, but it does stress it's a bad idea. ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2020-02-22 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (98 votes). Check out past polls.

    Notices?