Skip to content

Commit

Permalink
$_ defaults to OUTER::<$_>
Browse files Browse the repository at this point in the history
no reason to hide this fact
  • Loading branch information
gfldex committed Jun 10, 2020
1 parent 754e41e commit b19f1f1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/Type/Block.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ A C<Block> is a code object meant for small-scale code reuse. A block is
created syntactically by a list of statements enclosed in curly braces.
Without an explicit signature or placeholder arguments, a block has C<$_>
as a positional argument
as a positional argument. Which defaults to the outer scope's $_. Thus it
will inherit the L<topic|/language/variables#index-entry-topic_variable> if possible.
my $block = { uc $_; };
say $block.^name; # OUTPUT: «Block␤»
say $block('hello'); # OUTPUT: «HELLO␤»
say {;}.signature; # OUTPUT: «(;; $_? is raw = OUTER::<$_>)␤»
A block can have a L<Signature|/type/Signature> between C<< -> >> or C<< <-> >>
and the block:
Expand Down

0 comments on commit b19f1f1

Please sign in to comment.