File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,28 @@ corresponding parameters.
55
55
56
56
say &slow.assuming(10000000).&bench; # OUTPUT: «(10000000 7.5508834)»
57
57
58
+ For a sub with arity greater than one, you can use C < Whatever > C < * > for all of the positional parameters that are not "assumed".
59
+
60
+ sub first-and-last ( $first, $last ) {
61
+ say "Name is $first $last";
62
+ }
63
+
64
+ my &surnamed-smith = &first-and-last.assuming( *, 'Smith' );
65
+
66
+ &surnamed-smith.( 'Joe' ); # OUTPUT: «Name is Joe Smith»
67
+
68
+ You can handle any combination of assumed and not assumed positional parameters:
69
+
70
+ sub longer-names ( $first, $middle, $last, $suffix ) {
71
+ say "Name is $first $middle $last $suffix";
72
+ }
73
+
74
+ my &surnamed-public = &longer-names.assuming( *, *, 'Public', * );
75
+
76
+ &surnamed-public.( 'Joe', 'Q.', 'Jr.'); # OUTPUT: «Name is Joe Q. Public Jr.»
77
+
78
+ (Multi-parameter examples adapted from brian d foy's post http://stackoverflow.com/a/43669837/215487)
79
+
58
80
= comment according to design docs it's Callable but in rakudo it's assuming is in Block
59
81
60
82
= head1 Operators
You can’t perform that action at this time.
0 commit comments