txt: ## kv.md
  kv
  
  Combined from primary sources listed below.
  
  # [In List](#___top "go to top of document")[§](#(List)_routine_kv "direct link")
  
  See primary documentation
  [in context](/type/List#routine_kv)
  for **routine kv**.
  
  ```raku
  sub    kv($list --> Seq:D)
  method kv(List:D: --> Seq:D)
  ```
  
  Returns an interleaved sequence of indexes and values. For example
  
  ```raku
  say <a b c>.kv; # OUTPUT: «(0 a 1 b 2 c)␤»
  ```
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_kv)
  for **method kv**.
  
  ```raku
  method kv(Baggy:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of keys and values interleaved.
  
  ```raku
  my $breakfast = bag <eggs spam spam spam>;
  say $breakfast.kv;                                # OUTPUT: «(spam 3 eggs 1)␤»
  
  my $n = ("a" => 5, "b" => 2, "a" => 1).BagHash;
  say $n.kv;                                        # OUTPUT: «(a 6 b 2)␤»
  ```
  
  # [In Capture](#___top "go to top of document")[§](#(Capture)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Capture#method_kv)
  for **method kv**.
  
  ```raku
  multi method kv(Capture:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of alternating [keys](#method_keys) and [values](#method_values). The positional keys and values, if any, comes first followed by the named keys and values.
  
  ```raku
  my $capture = \(2, 3, apples => (red => 2));
  say $capture.kv; # OUTPUT: «(0 2 1 3 apples red => 2)␤»
  ```
  
  # [In role Enumeration](#___top "go to top of document")[§](#(role_Enumeration)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Enumeration#method_kv)
  for **method kv**.
  
  ```raku
  multi method kv(::?CLASS:D:)
  ```
  
  Returns a list with key and value of the enum-pair.
  
  ```raku
  say g.kv; # OUTPUT: «(g 1)␤»
  
  ```
  
  # [In Map](#___top "go to top of document")[§](#(Map)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Map#method_kv)
  for **method kv**.
  
  ```raku
  method kv(Map:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of keys and values interleaved.
  
  ```raku
  Map.new('a', 1, 'b', 2).kv  # (a 1 b 2)
  ```
  
  # [In Pair](#___top "go to top of document")[§](#(Pair)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Pair#method_kv)
  for **method kv**.
  
  ```raku
  multi method kv(Pair:D: --> List:D)
  ```
  
  Returns a two-element [`List`](/type/List) with the *key* and *value* parts of `Pair`, in that order. This method is a special case of the same-named method on [`Hash`](/type/Hash), which returns all its entries as a list of keys and values.
  
  ```raku
  my $p = (Raku => "d");
  say $p.kv[0]; # OUTPUT: «Raku␤»
  say $p.kv[1]; # OUTPUT: «d␤»
  ```
  
  # [In Any](#___top "go to top of document")[§](#(Any)_routine_kv "direct link")
  
  See primary documentation
  [in context](/type/Any#routine_kv)
  for **routine kv**.
  
  ```raku
  multi method kv(Any:U:)
  multi method kv(Any:D:)
  multi        kv($x)
  ```
  
  Returns an empty [`List`](/type/List) if the invocant is a type object:
  
  ```raku
  Sub.kv.say ;# OUTPUT: «()␤»
  ```
  
  It calls `list` on the invocant for value objects and returns the result of [List.kv](/type/List#routine_kv) on it as a list where keys and values will be ordered and contiguous
  
  ```raku
  <1 2 3>.kv.say; # OUTPUT: «(0 1 1 2 2 3)␤»
  ```
  
  In the case of [`Positional`](/type/Positional)s, the indices will be considered *keys*.
  
  # [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_kv "direct link")
  
  See primary documentation
  [in context](/type/Setty#method_kv)
  for **method kv**.
  
  ```raku
  multi method kv(Setty:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of the set's elements and `True` values interleaved.
  
  ```raku
  my $s = Set.new(1, 2, 3);
  say $s.kv;                                        # OUTPUT: «(3 True 1 True 2 True)␤»
  ```
  