Skip to content

Commit

Permalink
Document extra magic of $() 6.c shortcut
Browse files Browse the repository at this point in the history
It doesn't just stringify, but actually checks .ast value first
and returns it if it's truthy or stringifies match object if not.
  • Loading branch information
zoffixznet committed Sep 20, 2018
1 parent f55804f commit 2126875
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/Language/variables.pod6
Expand Up @@ -1032,15 +1032,15 @@ say $/;
# textnode => 「some text」␤»
=end code
To get a stringified version of the L<Match> object, simply use the
L<prefix ~ operator|https://docs.perl6.org/routine/~.html#(Operators)_prefix_~>.
In 6.c language, you can use C<$()> shortcut (no spaces inside the parentheses).
In 6.c language, you can use C<$()> shortcut (no spaces inside the parentheses) to get
the L<ast> value from C<$/> L<Match> if that value is truthy, or the stringification of the
L<Match> object otherwise.
'test' ~~ /.../;
say ~$/; # OUTPUT: «tes␤»
# 6.c language only:
say $(); # OUTPUT: «tes␤»;
$/.make: 'McTesty';
say $(); # OUTPUT: «McTesty␤»;
=head4 X«Positional attributes|variable,$0;variable,$1;variable,@()»
Expand Down

0 comments on commit 2126875

Please sign in to comment.