Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

24 lines (13 sloc) 0.418 kb
use v6;
use Test;
=begin description
This tests the &?BLOCK magical from Synopsis 6
=end description
# L<S06/The C<&?BLOCK> object>
plan 1;
# L<S02/Names/Which block am I in?>
# L<S06/The C<&?BLOCK> object/tail-recursion on an anonymous block:>
my $anonfactorial = -> Int $n { $n < 2 ?? 1 !! $n * &?BLOCK($n-1) };
my $result = $anonfactorial(3);
is($result, 6, 'the $?BLOCK magical worked');
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.