@@ -99,12 +99,13 @@ Or even
99
99
100
100
say { $^a ** 2 + $^b ** 2 }(3, 4) # OUTPUT: «25»
101
101
102
-
102
+ X < |pointy blocks >
103
103
= head2 X « Blocks and lambdas|syntax,-> »
104
104
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.
108
109
109
110
for 1, 2, 3, 4 -> $a, $b {
110
111
say $a ~ $b;
@@ -115,7 +116,17 @@ They can also be used on their own as anonymous blocks of code.
115
116
116
117
say { $^a ** 2 + $^b ** 2}(3, 4) # OUTPUT: «25»
117
118
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.
119
130
120
131
= head2 Signatures
121
132
0 commit comments