Documentation for routine unshift

Documentation for routine unshift, assembled from the following types:

class Any

From Any

(Any) method unshift

Defined As:

    method unshift(--> TODO)


class Array

From Array

(Array) routine unshift

Defined as:

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 infinite.


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

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

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

class Nil

From Nil

(Nil) method unshift

method unshift(*@)

Warns the user that they tried to unshift onto a Nil.