unshift
ErrorsCollection

unshift

Synthesised documentation from type/Buf type/Nil type/Any type/Array

From type/Buf

See Original text in context

method unshift()

Adds elements at the beginning of the buffer

$.unshift0 );
say $.raku# OUTPUT: «Buf.new(0,1,1,2,3,5,8,13,21,34,55,89)» 

From type/Nil

See Original text in context

method unshift(*@)

Warns the user that they tried to unshift onto a Nil or derived type object.

From type/Any

See Original text in context

multi method unshift(Any:U: --> Array)
multi method unshift(Any:U: @values --> Array)

Initializes Any variable as empty Array and calls Array.unshift on it.

my $a;
say $a.unshift# OUTPUT: «[]␤» 
say $a;         # OUTPUT: «[]␤» 
my $b;
say $b.unshift([1,2,3]); # OUTPUT: «[[1 2 3]]␤»

From type/Array

See Original text in context

multi sub    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:

my @foo = <a b c>;
@foo.unshift: 13 ... 11;
say @foo;                   # OUTPUT: «[(1 3 5 7 9 11) a b c]␤»

The notes in method push apply, regarding how many elements are added to the array.

The routine prepend is the equivalent for adding multiple elements from one list or array.