Function prototype: Difference between revisions
m
→{{header|Raku}}: Fix links and comments: Perl 6 --> Raku
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: Fix links and comments: Perl 6 --> Raku) |
||
Line 1,153:
=={{header|Raku}}==
(formerly Perl 6)
There is no restriction on placement of prototype declarations. (Actually, we call them "stub declarations".) In fact, stub declarations are rarely needed in
Note that the <tt>...</tt> in all of these stub bodies is literally part of the declaration syntax.
Line 1,174:
<lang perl6>sub foo ($, :$faster, :$cheaper --> Int) {...}</lang>
Example of prototype declarations for subroutines or procedures, which in
<lang perl6>sub foo ($, $ --> Nil) {...}</lang>
Line 1,183:
<lang perl6>sub foo ($, :$option! --> Int) {...}</lang>
A routine may unpack an <tt>Array</tt> automaticly. Here the first element is stored in a scalar and the rest in an <tt>Array</tt>. Other buildin types can be [http://design.
<lang perl6>sub foo ([$, @]) {...}</lang>
|