txt: ## keys.md
  keys
  
  Combined from primary sources listed below.
  
  # [In List](#___top "go to top of document")[§](#(List)_routine_keys "direct link")
  
  See primary documentation
  [in context](/type/List#routine_keys)
  for **routine keys**.
  
  ```raku
  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)`).
  
  ```raku
  say (1,2,3,4).keys; # OUTPUT: «(0 1 2 3)␤»
  ```
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_keys)
  for **method keys**.
  
  ```raku
  method keys(Baggy:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of all keys in the `Baggy` object without taking their individual weights into account as opposed to [kxxv](#method_kxxv).
  
  ```raku
  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)␤»
  ```
  
  # [In Capture](#___top "go to top of document")[§](#(Capture)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Capture#method_keys)
  for **method keys**.
  
  ```raku
  multi method keys(Capture:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) containing all positional keys followed by all named keys. For positional arguments the keys are the respective arguments ordinal position starting from zero.
  
  ```raku
  my $capture = \(2, 3, 5, apples => (red => 2));
  say $capture.keys; # OUTPUT: «(0 1 2 apples)␤»
  ```
  
  # [In Map](#___top "go to top of document")[§](#(Map)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Map#method_keys)
  for **method keys**.
  
  ```raku
  method keys(Map:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of all keys in the Map.
  
  ```raku
  my $m = Map.new('a' => (2, 3), 'b' => 17);
  say $m.keys; # OUTPUT: «(a b)␤»
  ```
  
  # [In Pair](#___top "go to top of document")[§](#(Pair)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Pair#method_keys)
  for **method keys**.
  
  ```raku
  multi method keys(Pair:D: --> List:D)
  ```
  
  Returns a [`List`](/type/List) containing the [key](/type/Pair#method_key) of the invocant.
  
  ```raku
  say (Raku => "d").keys;                           # OUTPUT: «(Raku)␤»
  ```
  
  # [In Any](#___top "go to top of document")[§](#(Any)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Any#method_keys)
  for **method keys**.
  
  ```raku
  multi method keys(Any:U: --> List)
  multi method keys(Any:D: --> List)
  ```
  
  For defined `Any` returns its [keys](/routine/keys) after calling `list` on it, otherwise calls `list` and returns it.
  
  ```raku
  my $setty = Set(<Þor Oðin Freija>);
  say $setty.keys; # OUTPUT: «(Þor Oðin Freija)␤»
  ```
  
  See also [`List.keys`](/type/List#routine_keys).
  
  Trying the same on a class will return an empty list, since most of them don't really have keys.
  
  # [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_keys "direct link")
  
  See primary documentation
  [in context](/type/Setty#method_keys)
  for **method keys**.
  
  ```raku
  multi method keys(Setty:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of all elements of the set.
  
  ```raku
  my $s = Set.new(1, 2, 3);
  say $s.keys;                                      # OUTPUT: «(3 1 2)␤»
  ```
  