Skip to content

Commit 38a6482

Browse files
committed
better example for .assuming
1 parent 3ef4a0c commit 38a6482

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

doc/Type/Callable.pod6

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ Returns a C<Callable> that implements the same behaviour as the
3333
original, but has the values passed to .assuming already bound to the
3434
corresponding parameters.
3535
36-
sub add(Int $x, Int $y) { $x + $y };
37-
my &add_to_5 = &add.assuming(5);
38-
say add_to_5(4); #-> 9
36+
my sub slow($n){ my $i = 0; $i++ while $i < $n; $i };
37+
38+
# takes only one parameter and as such wont forward $n
39+
sub bench(&c){ c, now - ENTER now };
40+
41+
say &slow.assuming(10000000).&bench;
42+
# OUTPUT«(10000000 7.5508834)␤»
3943
4044
=comment according to design docs it's Callable but in rakudo it's assuming is in Block
4145

0 commit comments

Comments
 (0)