Skip to content

Commit

Permalink
doc +@ in signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
gfldex committed Jun 15, 2016
1 parent c251707 commit 9efd021
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/Type/Signature.pod
Expand Up @@ -246,6 +246,24 @@ Slurpy parameters have special behaviors when combined with some
L<traits and modifiers|#Parameter_Traits_and_Modifiers>,
as described below.
=head2 Single Argument Rule Slurpy
The single argument rule allowes to treat arguments to subroutines,
C<for>-loops and list constructors based on context. Many methods on positional
types can work with a single arguments the same way then with a list or
arguments. Using C<+@> as a sigil in a Signature provides syntactic sugar to
make that task a little easier. Any single argument of a non-positional type
will be promoted to a list with a single item.
sub f(+@a){ dd @a };
f(1);
# OUTPUT«[1]␤»
f(1,2,3);
# OUTPUT«[1, 2, 3]␤»
my @b = <a b c>;
f @b;
# OUTPUT«["a", "b", "c"]␤»
=head2 Type Captures
Type Captures allow to defer the specification of a type constraint to the time
Expand Down

0 comments on commit 9efd021

Please sign in to comment.