File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1212,13 +1212,21 @@ unsuccessfully, resetting the answer to 42.
1212
1212
= head2 infix C « does »
1213
1213
1214
1214
= begin code :skip-test
1215
- sub infix:<does>(Mu $obj, Mu $role) is assoc<non>
1215
+ sub infix:<does>(Mu $obj, Mu $role) is assoc<non>
1216
+ sub infix:<does>(Mu $obj, Mu:D $obj) is assoc<non>
1216
1217
= end code
1217
1218
1218
1219
Mixes C < $role > into C < $obj > at run time. Requires C < $obj > to be mutable.
1219
1220
1220
- C < $role > doesn't need to a be a role, it can be something that knows how
1221
- to act like a role, for example enum values.
1221
+ Instead of a role, you can provide an instantiated object. In this case,
1222
+ the operator will create a role for you automatically. The role will contain
1223
+ a single method named the same as C < $obj.^name > and that returns C < $obj > :
1224
+
1225
+ say 42 but 'forty two'; # 'fourty two'
1226
+
1227
+ my $s = 12 but class { method ^name ($) { 'warbles' } }.new;
1228
+ say $s.warbles; # warbles.new
1229
+ say $s + 42; # 54
1222
1230
1223
1231
= head2 infix C « but »
1224
1232
You can’t perform that action at this time.
0 commit comments