@@ -363,8 +363,7 @@ Defined as:
363
363
proto method Hash(|) is nodal
364
364
multi method Hash( --> Hash:D)
365
365
366
-
367
- Coerce the invocant to L < Hash > by invoking the method C < hash > on it.
366
+ Coerce the invocant to L < Hash > .
368
367
369
368
= head2 method hash
370
369
@@ -374,15 +373,23 @@ Defined as:
374
373
multi method hash(Any:U: --> Hash:D)
375
374
multi method hash(Any:D: --> Hash:D)
376
375
377
- Creates a new L < Hash|/type/Hash > , empty in the case the invocant is
378
- undefined, or coerces the invocant to an C < Hash > in the case it is
379
- defined.
376
+ Coerces a type object to an empty L < Hash > .
377
+
378
+ More generally, coerces a defined invocant to something that supports the
379
+ L < Associative > role. This may be a mutable L < Hash > , but may also be
380
+ an immutable L < Map > or anything else that supports the L < Associative >
381
+ role. Use the C < .Hash > method if you really want to have a mutable L < Hash > ,
382
+ or the C < .Map > coercer if you're happy enough with an immutable L < Map > .
383
+ Use the C < .hash > coercer if you really don't care and want the cheapest
384
+ way to get an object that does the L < Associative > role.
380
385
381
386
= begin code
382
387
my $d; # $d is Any
383
388
say $d.hash; # OUTPUT: {}
384
- $d.append: 'a', 'b';
385
- say $d.hash; # OUTPUT: {a => b}
389
+
390
+ my %m is Map = a => 42, b => 666;
391
+ say %m.hash; # Map.new((a => 42, b => 666))
392
+ say %m.Hash; # {a => 42, b => 666}
386
393
= end code
387
394
388
395
= head2 method Slip
0 commit comments