Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: I should've known better!

by GrandFather (Saint)
on Sep 11, 2009 at 03:01 UTC ( [id://794677]=note: print w/replies, xml ) Need Help??


in reply to Re: I should've known better!
in thread I should've known better!

In Perl 5 my $var; ... for $var (...) {...} doesn't alter the contents of the $var global to the for loop. Is that true for both the -> and <-> variants of the Perl 6 for loop illustrated above?

I presume you can for @array <-> my $var {...} in Perl 6 to make the scope of $var obvious.


True laziness is hard work

Replies are listed 'Best First'.
Re^3: I should've known better!
by moritz (Cardinal) on Sep 14, 2009 at 14:16 UTC
    In Perl 5 my $var; ... for $var (...) {...} doesn't alter the contents of the $var global to the for loop. Is that true for both the -> and <-> variants of the Perl 6 for loop illustrated above?
    Yes.
    presume you can for @array <-> my $var {...}, in Perl 6 to make the scope of $var obvious.
    No, you can't. Both arrows actually introduce a signature, and my in a signature doesn't make sense.

    I used to write -> my $x too, but got used to omitting the my rather quickly :-).

    Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 22:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found