@@ -204,12 +204,24 @@ $x = $ok ?? $yes !! $no; # Perl 6
204
204
Although not fully documented, S03 indicates that the mathematical and
205
205
logical assignment operators should work as you would expect. The one
206
206
noticeable change is that C < .= > calls a mutating method on the object on
207
- the left, while C < ~= > is the string concatenation assignment, as you
208
- might expect with the changes in C < . > and C < ~ > . Also, the bitwise
209
- assignment operators are likely not separated into numeric and string
210
- versions (C < &= > , etc., vs. C < &.= > , etc.), as that feature is currently
211
- experimental in Perl 5 itself - although, again, this is not
212
- specifically documented.
207
+ the left (which can also be a type-object). This allows for the following
208
+ useful idiom:
209
+
210
+ = begin code
211
+ class LongClassName {
212
+ has $.frobnicate;
213
+ }
214
+ my LongClassName $bar .= new( frobnicate => 42 ); # no need to repeat class name
215
+ = end code
216
+
217
+ This ensures that C < $bar > will only be able to contain a C < LongClassName >
218
+ object, as well not having to repeat (and possibly misspell) the class name.
219
+
220
+ C < ~= > is the string concatenation assignment, as you might expect with the
221
+ changes in C < . > and C < ~ > . Also, the bitwise assignment operators are likely
222
+ not separated into numeric and string versions (C < &= > , etc., vs. C < &.= > , etc.),
223
+ as that feature is currently experimental in Perl 5 itself - although, again,
224
+ this is not specifically documented.
213
225
214
226
= head2 Comma Operator
215
227
0 commit comments