Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Using ternary operator as lvalue in push

by dada (Chaplain)
on Aug 01, 2007 at 09:54 UTC ( #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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2022-01-28 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?