Documentation for routine keys assembled from the following pages:

Role: Baggy §

From Baggy

(Baggy) method keys §

Defined as:

method keys(Baggy:D: --> Seq:D)

Returns a Seq of all keys in the Baggy object without taking their individual weights into account as opposed to kxxv.

my $breakfast = bag <eggs spam spam spam>;
say $breakfast.keys.sort;                        # OUTPUT: «(eggs spam)␤» 
 
my $n = ("a" => 5"b" => 2).BagHash;
say $n.keys.sort;                                # OUTPUT: «(a b)␤»

Class: Any §

From Any

(Any) method keys §

Defined as:

multi method keys(Any:U: --> List)
multi method keys(Any:D: --> List)

For defined Any returns its keys after calling list on it, otherwise calls list and returns it.

my $setty = Set(<Þor Oðin Freija>);
say $setty.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.

Class: List §

From List

(List) routine keys §

Defined as:

sub    keys($list --> Seq:D)
method keys(List:D: --> Seq:D)

Returns a sequence of indexes into the list (e.g., 0..(@list.elems-1)).

say (1,2,3,4).keys# OUTPUT: «0..3␤»

Class: Map §

From Map

(Map) method keys §

Defined as:

method keys(Map:D: --> Seq:D)

Returns a Seq of all keys in the Map.

my $m = Map.new('a' => (23), 'b' => 17);
say $m.keys# OUTPUT: «(a b)␤»

Role: Setty §

From Setty

(Setty) method keys §

Defined as:

multi method keys(Setty:D: --> Seq:D)

Returns a Seq of all elements of the set.

my $s = Set.new(123);
say $s.keys;                                      # OUTPUT: «(3 1 2)␤»

Class: Pair §

From Pair

(Pair) method keys §

Defined as:

multi method keys(Pair:D: --> List:D)

Returns a List containing the key of the invocant.

say (Raku => "d").keys;                           # OUTPUT: «(Raku)␤»

Class: Capture §

From Capture

(Capture) method keys §

Defined as:

multi method keys(Capture:D: --> Seq:D)

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 $capture = \(235apples => (red => 2));
say $capture.keys# OUTPUT: «(0 1 2 apples)␤»