txt: ## unshift.md
  unshift
  
  Combined from primary sources listed below.
  
  # [In Any](#___top "go to top of document")[§](#(Any)_method_unshift "direct link")
  
  See primary documentation
  [in context](/type/Any#method_unshift)
  for **method unshift**.
  
  ```raku
  multi method unshift(Any:U: --> Array)
  multi method unshift(Any:U: @values --> Array)
  ```
  
  Initializes `Any` variable as empty [`Array`](/type/Array) and calls [`Array.unshift`](/type/Array#routine_unshift) on it.
  
  ```raku
  my $a;
  say $a.unshift; # OUTPUT: «[]␤»
  say $a;         # OUTPUT: «[]␤»
  my $b;
  say $b.unshift([1,2,3]); # OUTPUT: «[[1 2 3]]␤»
  ```
  
  # [In Array](#___top "go to top of document")[§](#(Array)_routine_unshift "direct link")
  
  See primary documentation
  [in context](/type/Array#routine_unshift)
  for **routine unshift**.
  
  ```raku
  multi        unshift(Array:D, **@values --> Array:D)
  multi method unshift(Array:D: **@values --> Array:D)
  ```
  
  Adds the `@values` to the start of the array, and returns the modified array. Fails if `@values` is a lazy list.
  
  Example:
  
  ```raku
  my @foo = <a b c>;
  @foo.unshift: 1, 3 ... 11;
  say @foo;                   # OUTPUT: «[(1 3 5 7 9 11) a b c]␤»
  ```
  
  The notes in [the documentation for method push](/type/Array#method_push) apply, regarding how many elements are added to the array.
  
  The [routine prepend](/type/Array#routine_prepend) is the equivalent for adding multiple elements from one list or array.
  
  # [In role Buf](#___top "go to top of document")[§](#(role_Buf)_method_unshift "direct link")
  
  See primary documentation
  [in context](/type/Buf#method_unshift)
  for **method unshift**.
  
  ```raku
  method unshift()
  ```
  
  Inserts elements at the beginning of the buffer.
  
  ```raku
  my $bú = Buf.new( 1, 1, 2, 3, 5 );
  $bú.unshift( 0 );
  say $bú.raku; # OUTPUT: «Buf.new(0,1,1,2,3,5)␤»
  ```
  
  # [In IterationBuffer](#___top "go to top of document")[§](#(IterationBuffer)_method_unshift "direct link")
  
  See primary documentation
  [in context](/type/IterationBuffer#method_unshift)
  for **method unshift**.
  
  ```raku
  method unshift(IterationBuffer:D: Mu \value)
  ```
  
  Adds the given value at the beginning of the `IterationBuffer` and returns the given value. Available as of the 2021.12 release of the Rakudo compiler.
  
  # [In Nil](#___top "go to top of document")[§](#(Nil)_method_unshift "direct link")
  
  See primary documentation
  [in context](/type/Nil#method_unshift)
  for **method unshift**.
  
  ```raku
  method unshift(*@)
  ```
  
  Warns the user that they tried to unshift onto a `Nil` or derived type object.
  