@@ -197,7 +197,7 @@ C<trusts>. A forward declaration of the tuested class may be required.
197
197
method change { $!a!A::foo = 42; self }
198
198
};
199
199
say B.new.change;
200
- OUTPUT « B.new(a => A.new(foo => 42)) »
200
+ # OUTPUT « B.new(a => A.new(foo => 42)) »
201
201
202
202
TODO
203
203
@@ -259,6 +259,7 @@ Stringification of the symbol will provide the key of the enum-pair.
259
259
Comparing symbols will use type information and the value of the enum-pair. As
260
260
value types C < Numerical > an C < Str > are supported.
261
261
262
+ enum Names ( name1 => 1, name2 => 2 );
262
263
sub same(Names $a, Names $b){
263
264
$a eqv $b
264
265
}
@@ -312,32 +313,38 @@ Returns the list of enum-pairs. Works both on the enum type and any key.
312
313
313
314
Returns the key of an enum-pair.
314
315
316
+ = for code :skip-test
315
317
say g.key; # OUTPUT « g »
316
318
317
319
= head4 method value
318
320
319
321
Returns the value of an enum-pair.
320
322
323
+ = for code :skip-test
321
324
say g.value; # OUTPUT « 1 »
322
325
323
326
= head4 method pair
324
327
325
328
Defined as:
326
329
330
+ = for code :skip-test
327
331
method pair(::?CLASS:D:)
328
332
329
333
Returns a C < Pair > of the enum-pair.
330
334
335
+ = for code :skip-test
331
336
say g.pair; # OUTPUT « g => 1 »
332
337
333
338
= head4 method kv
334
339
335
340
Defined as:
336
341
342
+ = for code :skip-test
337
343
multi method kv(::?CLASS:D:)
338
344
339
345
Returns a list with key and value of the enum-pair.
340
346
347
+ = for code :skip-test
341
348
say g.kv; # OUTPUT « (g 1) »
342
349
343
350
@@ -383,6 +390,8 @@ will be checked against the given code object.
383
390
384
391
subset Positive of Int where * > -1;
385
392
my Positive $i = 1;
386
- $i = -42; # OUTPUT « Type check failed in assignment to $i; expected Positive but got Int (-42) … »
393
+ $i = -42;
394
+ CATCH { default { put .^name,': ', .Str } }
395
+ # OUTPUT « X::TypeCheck::Assignment: Type check failed in assignment to $i; expected Positive but got Int (-42) … »
387
396
388
397
= end pod
0 commit comments