Object hashes with a limitation on the type of values
QuantHashes are what set operators use internally.
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.
QuantHash object to a Hash (by stringifying the objects for the keys) without any limitations on the values, and returns that.
Returns the type of value a key of this subclass of
QuantHash may have. This is typically Mu, which is also the default for punned QuantHashes.
method Setty(--> Setty)
my is Bag = one => 1, two => 2;say .Setty; # OUTPUT: «Set(one two)␤»my is Mix = one => 1, minus => -1;say .Setty; # OUTPUT: «Set(one)␤»
method Baggy(--> Baggy)
my is Set = <one two>;say .Baggy; # OUTPUT: «Bag(one two)␤»my is Mix = one => 1, minus => -1;say .Baggy; # OUTPUT: «Bag(one)␤»
method Mixy(--> Mixy)
QuantHash object to the equivalent object that uses the Mixy role.
my is Set = <one two>;say .Mixy; # OUTPUT: «Mix(one two)␤»my is Bag = one => 1, two => 2;say .Mixy; # OUTPUT: «Mix(one two(2))␤»
QuantHash does role Associative, which provides the following routines:
Associative is actually a parameterized role which can use different classes for keys and values. As seen at the top of the document, by default it coerces to
Str for the key and uses a very generic
Mu for value.
my ;say .of;# OUTPUT: «(Mu)␤»
The value is the first parameter you use when instantiating
Associative with particular classes:
is Hash does Associative[Cool,DateTime] ;my := DateHash.new;say .of; # OUTPUT: «(Cool)␤»
Returns the parameterized key used for the Associative role, which is
Any coerced to
Str by default. This is the class used as second parameter when you use the parameterized version of Associative.
my ;.keyof; #OUTPUT: «(Str(Any))␤»
Should return the value / container at the given key.
Should return a
Bool indicating whether the given key actually has a value.
method STORE(\values, :)
This method should only be supplied if you want to support the:
my is Foo = a => 42, b => 666;
syntax for binding your implementation of the
Should accept the values to (re-)initialize the object with, which either could consist of
Pairs, or separate key/value pairs. The optional named parameter will contain a
True value when the method is called on the object for the first time. Should return the invocant.