method hash
1 | class Capture |
1.1 | (Capture) method hash |
2 | class Any |
2.1 | (Any) method hash |
3 | role Baggy |
3.1 | (Baggy) method hash |
4 | class Match |
4.1 | (Match) method hash |
5 | role QuantHash |
5.1 | (QuantHash) method hash |
Documentation for method hash
assembled from the following types:
class Capture
From Capture
(Capture) method hash
Defined as:
method hash(Capture:)
Returns the named/hash part of the Capture.
my Capture = \(2, 3, 5, apples => (red => 2));say .hash; # OUTPUT: «Map.new((:apples(:red(2))))»
class Any
From Any
(Any) method hash
Defined as:
multi method hash(Any:)multi method hash(Any:)
When called on a type object, returns an empty Hash. On instances, it is equivalent to assigning the invocant to a %-
sigiled variable and returning that.
Subclasses of Any
may choose to return any core type that does the Associative role from .hash
. Use .Hash
to coerce specifically to Hash.
my ; # $d is Anysay .hash; # OUTPUT: {}my is Map = a => 42, b => 666;say .hash; # Map.new((a => 42, b => 666))say .Hash; # {a => 42, b => 666}
role Baggy
From Baggy
(Baggy) method hash
Defined as:
method hash(Baggy: --> Hash)
Returns a Hash where the elements of the invocant are the keys and their respective weights the values.
my = bag <eggs bacon bacon>;my = .hash;say .^name; # OUTPUT: «Hash[Any,Any]»say ; # OUTPUT: «{bacon => 2, eggs => 1}»
class Match
From Match
(Match) method hash
Returns a hash of named submatches.
role QuantHash
From QuantHash
(QuantHash) method hash
method hash()
Coerces the QuantHash
object to a Hash (by stringifying the objects for the keys) with the values of the hash limited to the same limitation as QuantHash
, and returns that.