We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51a6853 commit 4356fbfCopy full SHA for 4356fbf
doc/Type/Callable.pod6
@@ -41,6 +41,17 @@ container, is has to implement Callable.
41
my &a = A;
42
say a(); # OUTPUT: «called»
43
44
+Applying the Callable role is not a requirement, however, should a class simply want to add subroutine-like semantics in a regular scalar container.
45
+
46
+ class A {
47
+ has @.values;
48
+ submethod CALL-ME(Int $x where 0 <= * < @!values.elems) {
49
+ @!values[$x]
50
+ }
51
52
+ my $a = A.new: values => [4,5,6,7]
53
+ say $a(2); # OUTPUT: «6»
54
55
=head2 method Capture
56
57
Defined as:
@@ -51,4 +62,4 @@ Throws C<X::Cannot::Capture>.
62
63
=end pod
64
-# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
65
+# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
0 commit comments