Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: On Scalar Context ("list")

by Errto (Vicar)
on Apr 24, 2004 at 02:04 UTC ( #347807=note: print w/ replies, xml ) Need Help??


in reply to Re: On Scalar Context ("list")
in thread On Scalar Context

Although it gets a bit hairy, one can explain that behavior by saying that my $a = (10,20,30); is merely an application of the comma operator in scalar context, whereas the rhs of my $a = (10,20,30)[0..2] is really a list, and so the behavior of taking the last value has to be explicitly defined. The distinction is important because I believe that  my $a = (1,2,foo) would call foo in scalar context, but my $a = (1,2,foo)[0..2] would call it in list context.

The preceding paragraph will be moot someday because according to Apocalypse 3, there will be no scalar comma operator in Perl 6 - it will always be a list, and a list in scalar context will return an array reference


Comment on Re: Re: On Scalar Context ("list")
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2015-07-03 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (49 votes), past polls