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 ecc15e2 commit 53ef347Copy full SHA for 53ef347
doc/Type/Sub.pod6
@@ -6,12 +6,20 @@
6
7
class Sub is Routine { }
8
9
-A type for subroutines. Subs are created with the C<sub> declarator keyword
+A type for subroutines. Subs are created with the C<sub> declarator keyword followed by a identifier.
10
11
my $s = sub ($a, $b) { $a + $b };
12
say $s.WHAT; # (Sub)
13
say $s(2, 5); # 7
14
15
+Note that subs that go by the same name as
16
+L<coercers|/language/typesystem#Coercion> will not take precedence over
17
+coercers. To call them use the C<&>-sigil.
18
+
19
+ sub Int(Str $s){'oi‽'};
20
+ say [Int, Int('42'),&Int('42')];
21
+ # OUTPUT«[(Int) 42 oi‽]»
22
23
=head1 Traits
24
X<|trait_mod (declarator)>
25
0 commit comments