Em Ter, 2009-09-15 às 19:33 -0400, Aaron Sherman escreveu:
> I tried this out, and I'm not 100% certain why I got what I did (#20
> release):
> Code:
> my $x = \(-> { say "Perl 6" }); say $x();
> Output:
> Perl 6
> 1
> First off, why can I invoke a capture when it contains a lambda? Shouldn't I
> get an error, here?
This is because, in order to DWYM, a capture with a single element in
item context returns that element. When you do $x(), you're using it as
item, and it will call .() on the element inside the capture.
This might seem confusing, but it's the only way to make
return 1;
work as expected.
> Second, why the 1? Is that the return value of the lambda?
Yes.