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 cd879ef commit d658a1bCopy full SHA for d658a1b
doc/Language/functions.pod6
@@ -174,6 +174,19 @@ values.
174
put b.perl;
175
# OUTPUT«\("a", "b", "c")»
176
177
+=head2 Return Type Constraints
178
+
179
+Perl 6 has many ways to specify a function's return type:
180
181
+ sub foo(--> Int) {}; say &foo.returns # (Int)
182
+ sub foo() returns Int {}; say &foo.returns # (Int)
183
+ sub foo() of Int {}; say &foo.returns # (Int)
184
+ my Int sub foo() {}; say &foo.returns # (Int)
185
186
+Attempting to return values of another type will cause a compilation error.
187
188
+ sub foo() returns Int { "a"; }; foo; # Type check fails
189
190
=head2 X<Multi-dispatch|declarator,multi>
191
192
Perl 6 allows you to write several routines with the same name, but different
0 commit comments