Skip to content

Commit

Permalink
fixup now-tested code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Nov 2, 2018
1 parent 1149bd2 commit 24e1691
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions doc/Language/5to6-nutshell.pod6
Expand Up @@ -277,7 +277,7 @@ variable holding a code object as an argument:
first_index { $_ > 5 } @values;
&first_index($coderef, @values); # (disabling the prototype that parses a
# literal block as the first argument)
=for code
=for code :preamble<my @values; my $coderef>
# Perl 6:
first { $_ > 5 }, @values, :k; # the :k makes first return an index
first $coderef, @values, :k;
Expand All @@ -294,7 +294,8 @@ exact equivalent in Perl 5.
=for code :lang<perl5>
sub foo { say "before"; &bar; say "after" } # Perl 5
=for code
=for code :preamble<sub bar() {...}>
sub foo { say "before"; bar(|@_); say "after" } # Perl 6 - have to be explicit
Expand Down
2 changes: 1 addition & 1 deletion doc/Language/subscripts.pod6
Expand Up @@ -59,7 +59,7 @@ as if they were postcircumfix operators:
This is really just syntactic sugar that gets turned into the corresponding
C<{ }> form at compile-time:
=begin code
=begin code :preamble<my %hash;my $var>
%hash<foo bar>; # same as %hash{ <foo bar> }
%hash«foo "$var"»; # same as %hash{ «foo "$var"» }
%hash<<foo "$var">>; # same as %hash{ <<foo "$var">> }
Expand Down

0 comments on commit 24e1691

Please sign in to comment.