Skip to content

Commit 612fcac

Browse files
committed
Adds index, and also add examples. Closes #2835
1 parent 77e9415 commit 612fcac

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

doc/Language/functions.pod6

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ Or even
9999
100100
say { $^a ** 2 + $^b ** 2 }(3, 4) # OUTPUT: «25␤»
101101
102-
102+
X<|pointy blocks>
103103
=head2 X«Blocks and lambdas|syntax,->»
104104
105-
Whenever you see something like C«{ $_ + 42 }»,
106-
C«-> $a, $b { $a ** $b }», or C«{ $^text.indent($:spaces) }», that's
107-
L<Block|/type/Block> syntax. It's used after every C<if>, C<for>, C<while>, etc.
105+
Whenever you see something like C«{ $_ + 42 }», C«-> $a, $b { $a ** $b }», or
106+
C«{ $^text.indent($:spaces) }», that's L<Block|/type/Block> syntax; the C<->> is
107+
considered also part of the block. Statements such as C<if>, C<for>, C<while>
108+
are followed by these kind of blocks.
108109
109110
for 1, 2, 3, 4 -> $a, $b {
110111
say $a ~ $b;
@@ -115,7 +116,17 @@ They can also be used on their own as anonymous blocks of code.
115116
116117
say { $^a ** 2 + $^b ** 2}(3, 4) # OUTPUT: «25␤»
117118
118-
For block syntax details, see the documentation for the L<Block|/type/Block> type.
119+
Please note that this implies that, despite the fact that statements such as
120+
C<if> do not define a topic variable, they actually can:
121+
122+
=for code
123+
my $foo = 33;
124+
if $foo ** 33 -> $a {
125+
say "$a is not null"; #
126+
} # OUTPUT: «129110040087761027839616029934664535539337183380513 is not null␤»
127+
128+
For block syntax details, see the documentation for the L<Block|/type/Block>
129+
type.
119130
120131
=head2 Signatures
121132

0 commit comments

Comments
 (0)