txt: ## shift.md
  shift
  
  Combined from primary sources listed below.
  
  # [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_shift "direct link")
  
  See primary documentation
  [in context](/type/independent-routines#sub_shift)
  for **sub shift**.
  
  ```raku
  multi shift(@a) is raw
  ```
  
  Calls method `shift` on the [`Positional`](/type/Positional) argument. That method, on a mutable collection that actually implements it (such as an [`Array`](/routine/shift#(Array)_method_shift) or a [`Buf`](/type/Buf#method_shift)), is supposed to remove and return the first element, or return a [`Failure`](/type/Failure) if the collection is empty.
  
  Example:
  
  ```raku
  say shift [1,2]; # OUTPUT: «1␤»
  ```
  
  ```raku
  my @a of Int = [1];
  say shift @a; # OUTPUT: «1␤»
  say shift @a; # ERROR: «Cannot shift from an empty Array[Int]␤»
  
  ```
  
  # [In Array](#___top "go to top of document")[§](#(Array)_method_shift "direct link")
  
  See primary documentation
  [in context](/type/Array#method_shift)
  for **method shift**.
  
  ```raku
  method shift(Array:D:) is nodal
  ```
  
  Removes and returns the first item from the array. Fails if the array is empty.
  
  Example:
  
  ```raku
  my @foo = <a b>;
  say @foo.shift;             # OUTPUT: «a␤»
  say @foo.shift;             # OUTPUT: «b␤»
  say @foo.shift;
  CATCH { default { put .^name, ': ', .Str } };
  # OUTPUT: «X::Cannot::Empty: Cannot shift from an empty Array␤»
  ```
  
  # [In role Buf](#___top "go to top of document")[§](#(role_Buf)_method_shift "direct link")
  
  See primary documentation
  [in context](/type/Buf#method_shift)
  for **method shift**.
  
  ```raku
  method shift()
  ```
  
  Removes and returns the first element of the buffer.
  
  ```raku
  my $bú = Buf.new( 1, 1, 2, 3, 5 );
  say $bú.shift(); # OUTPUT: «1␤»
  say $bú.raku;    # OUTPUT: «Buf.new(1,2,3,5)␤»
  ```
  