Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Using ternary operator as lvalue in push

by dada (Chaplain)
on Aug 01, 2007 at 09:54 UTC ( [id://630006]=note: print w/replies, xml ) Need Help??


in reply to Re: Using ternary operator as lvalue in push
in thread Using ternary operator as lvalue in push

ouch... I'm oha's friend :-)

of course, I tested it with:
# This is perl, v5.8.7 my @a = (1,2,3); my @b = (4,5,6); push 1==1 ? @a : @b, "foo"; print "a=@a b=@b\n";
I even counter-checked (!) it with:
push 1==0 ? @a : @b, "foo";
to verify that the "foo" was pushed into @b.

of course, such stupid conditionals are optimized away. sorry for fooling myself, oha, and probably others. shame on me :-)

cheers,
Aldo

King of Laziness, Wizard of Impatience, Lord of Hubris

Replies are listed 'Best First'.
Re^3: Using ternary operator as lvalue in push
by FunkyMonk (Chancellor) on Aug 01, 2007 at 10:38 UTC
    Compile time constant removal magic.

    perl -MO=Deparse play produces:

    my(@a) = (1, 2, 3); my(@b) = (4, 5, 6); push @a, 'foo'; print "a=@a b=@b\n";

    /msg self Read ALL the post before replying

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-25 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found