Acme-Lambda
view release on metacpan or search on metacpan
t/02-onearg.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More qw(no_plan);
=head1 DESCRIPTION
Test the use of $_ to access the lambda's first argument
=cut
use Acme::Lambda;
my $square = lambda { $_ * $_ };
is($square->(4), 16);
use utf8;
my $cube = λ {$_ * $_ * $_};
is($cube->(3), 27);
# Make sure lambda doesn't clobber $_
$_ = "something";
lambda{$_}->('else');
is($_, "something");
( run in 1.940 second using v1.01-cache-2.11-cpan-5511b514fd6 )