Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^3: ~~ and list literal

by ikegami (Pope)
on Oct 27, 2012 at 00:15 UTC ( #1001146=note: print w/replies, xml ) Need Help??

in reply to Re^2: ~~ and list literal
in thread ~~ and list literal

Why does "x" ~~ "a", "b", "c" always give 1?

It doesn't; it evaluates to "c".

"," is a very low precedence operator. "x" ~~ "a", "b", "c" means ("x" ~~ "a"), "b", "c", which evaluates to "c" in scalar context.

And why does "x" ~~ sub { "a", "b", "c" } also give 1?

It doesn't; it evaluates to "c".

"x" ~~ sub { "a", "b", "c" } is the same as scalar( sub { "a", "b", "c" }->($x) ). Since  "a", "b", "c" evaluates to "c" in scalar context, that is what is returned.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-10-24 06:48 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (303 votes). Check out past polls.