Front page | perl.perl6.language |
Postings from March 2005
Re: for @list ⊂
Thread Previous
|
Thread Next
From:
Luke Palmer
Date:
March 12, 2005 17:54
Subject:
Re: for @list ⊂
Message ID:
20050313015617.GA4922@navi.cx
Rod Adams writes:
> Are the following all legal and equivalent?
>
> for 1..10 -> $a, $b { say $a, $b };
>
> for 1..10 { say $^a, $^b };
>
> sub foo ($a, $b) { say $a, $b };
> for 1..10 &foo;
Almost. The last one should be:
for 1..10, &foo;
> What happens with:
>
> for 1..10 -> *@a { say @a };
Good question. That's a function of how C<for> interprets the arity. The
formal arity of a sub with *@ is Inf, so I suppose say would get 1..10
and the loop would run once.
That's probably the best way for C<for> to behave, because that's what
I'd expect in this case.
Luke
Thread Previous
|
Thread Next