routine keys
1 | class List |
1.1 | (List) routine keys |
2 | class Capture |
2.1 | (Capture) method keys |
3 | class Any |
3.1 | (Any) method keys |
4 | role Baggy |
4.1 | (Baggy) method keys |
5 | role Setty |
5.1 | (Setty) method keys |
6 | class Pair |
6.1 | (Pair) method keys |
7 | class Map |
7.1 | (Map) method keys |
Documentation for routine keys
assembled from the following types:
class List
From List
(List) routine keys
Defined as:
sub keys( --> Seq)method keys(List: --> Seq)
Returns a sequence of indexes into the list (e.g., 0..(@list.elems-1)
).
say (1,2,3,4).keys; # OUTPUT: «0..3»
class Capture
From Capture
(Capture) method keys
Defined as:
multi method keys(Capture: --> Seq)
Returns a Seq containing all positional keys followed by all named keys. For positional arguments the keys are the respective arguments ordinal position starting from zero.
my = \(2, 3, 5, apples => (red => 2));say .keys; # OUTPUT: «(0 1 2 apples)»
class Any
From Any
(Any) method keys
Defined as:
multi method keys(Any: --> List)multi method keys(Any: --> List)
For defined Any returns its keys after calling list
on it, otherwise calls list
and returns it.
my = Set(<Þor Oðin Freija>);say .keys; # OUTPUT: «(Þor Oðin Freija)»
See also List.keys
.
Trying the same on a class will return an empty list, since most of them don't really have keys.
role Baggy
From Baggy
(Baggy) method keys
Defined as:
method keys(Baggy: --> Seq)
Returns a Seq
of all keys in the Baggy
object without taking their individual weights into account as opposed to kxxv.
my = bag <eggs spam spam spam>;say .keys.sort; # OUTPUT: «(eggs spam)»my = ("a" => 5, "b" => 2).BagHash;say .keys.sort; # OUTPUT: «(a b)»
role Setty
From Setty
(Setty) method keys
Defined as:
multi method keys(Setty: --> Seq)
Returns a Seq of all elements of the set.
my = Set.new(1, 2, 3);say .keys; # OUTPUT: «(3 1 2)»
class Pair
From Pair
(Pair) method keys
Defined as:
multi method keys(Pair: --> List)
Returns a List containing the key of the invocant.
say ('Perl' => 6).keys; # OUTPUT: «(Perl)»
class Map
From Map
(Map) method keys
Defined as:
method keys(Map: --> Seq)
Returns a Seq
of all keys in the Map.
my = Map.new('a' => (2, 3), 'b' => 17);say .keys; # OUTPUT: «(a b)»