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

Re: question 1st - undefined behaviour

by Riales (Hermit)
on Sep 23, 2013 at 22:03 UTC ( #1055392=note: print w/ replies, xml ) Need Help??


in reply to question 1st - undefined behaviour

I think the first and second $x would be 6 actually, due to the prepend happening on the second $x.

Here are the steps in order:

1. ++$x: All $x are now 6.

2. 6 + 6 + 6

3. $x++: All $x are now 7.

4. $x = 18: The value from the 6 + 6 + 6 is assigned to $x.


Comment on Re: question 1st - undefined behaviour
Select or Download Code
Re^2: question 1st - undefined behaviour
by rumos2 (Novice) on Sep 23, 2013 at 22:21 UTC
    sorry if I making a mistake, but looks like you are wrong - why - try understand why
    my $x=5; $x=++$x + $x++ + $x; warn $x;
    return's 20.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2014-12-18 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (61 votes), past polls