Skip to content

Commit d11caf6

Browse files
committed
make examples compile
1 parent 77acc0f commit d11caf6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

doc/Language/functions.pod6

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,23 @@ values.
178178
179179
Perl 6 has many ways to specify a function's return type:
180180
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)
181+
=for code :skip-test
182+
sub foo(--> Int) {}; say &foo.returns; # (Int)
183+
sub foo() returns Int {}; say &foo.returns; # (Int)
184+
sub foo() of Int {}; say &foo.returns; # (Int)
185+
my Int sub foo() {}; say &foo.returns; # (Int)
185186
186187
Attempting to return values of another type will cause a compilation error.
187188
188-
sub foo() returns Int { "a"; }; foo; # Type check fails
189+
=for code :catch-all
190+
sub foo() returns Int { "a"; }; foo; # Type check fails
189191
190192
Note that C<Nil> and C<Failure> are excempt from return type constraints and
191193
can be returned from any routine, regardless of its constraint:
192194
193-
sub foo() returns Int { fail }; foo; # Failure returned
194-
sub foo() returns Int { return }; foo; # Nil returned
195+
=for code :catch-all
196+
sub foo() returns Int { fail }; foo; # Failure returned
197+
sub bar() returns Int { return }; bar; # Nil returned
195198
196199
=head2 X<Multi-dispatch|declarator,multi>
197200

0 commit comments

Comments
 (0)