@@ -475,30 +475,30 @@ consistency, it is the only form accepted on this site.
475
475
The return type arrow has to be placed at the end of the parameter list,
476
476
with or without a C < , > before it.
477
477
478
- = begin code
479
- sub greeting1(Str $name --> Str) { say "Hello, $name" } # Valid
480
- sub greeting2(Str $name, --> Str) { say "Hello, $name" } # Valid
478
+ = begin code
479
+ sub greeting1(Str $name --> Str) { say "Hello, $name" } # Valid
480
+ sub greeting2(Str $name, --> Str) { say "Hello, $name" } # Valid
481
481
482
- sub favorite-number1(--> 42) { } # OUTPUT: 42
483
- sub favorite-number2(--> 42) { return } # OUTPUT: 42
484
- = end code
482
+ sub favorite-number1(--> 42) { } # OUTPUT: 42
483
+ sub favorite-number2(--> 42) { return } # OUTPUT: 42
484
+ = end code
485
485
486
486
If the type constraint is a constant expression, it is used as the
487
487
return value of the routine. Any return statement in that routine has to
488
488
be argumentless.
489
489
490
- = begin code
491
- sub foo(Str $word --> 123) { say $word; return; }
492
- my $value = foo("hello"); # OUTPUT: hello
493
- say $value; # OUTPUT: 123
494
- = end code
495
-
496
- = begin code :skip-test<compile time error>
497
- # The code below will not compile
498
- sub foo(Str $word --> 123) { say $word; return $word; }
499
- my $value = foo("hello");
500
- say $value;
501
- = end code
490
+ = begin code
491
+ sub foo(Str $word --> 123) { say $word; return; }
492
+ my $value = foo("hello"); # OUTPUT: hello
493
+ say $value; # OUTPUT: 123
494
+ = end code
495
+
496
+ = begin code :skip-test<compile time error>
497
+ # The code below will not compile
498
+ sub foo(Str $word --> 123) { say $word; return $word; }
499
+ my $value = foo("hello");
500
+ say $value;
501
+ = end code
502
502
503
503
= head4 C < returns >
504
504
0 commit comments