In Nil§
See primary documentation in context for method unshift
method unshift(*@)
Warns the user that they tried to unshift onto a Nil
or derived type object.
In Array§
See primary documentation in context for routine unshift
multi unshift(Array, ** --> Array)multi method unshift(Array: ** --> Array)
Adds the @values
to the start of the array, and returns the modified array. Fails if @values
is a lazy list.
Example:
my = <a b c>;.unshift: 1, 3 ... 11;say ; # 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.
The routine prepend is the equivalent for adding multiple elements from one list or array.
In role Buf§
See primary documentation in context for method unshift
method unshift()
Inserts elements at the beginning of the buffer.
my = Buf.new( 1, 1, 2, 3, 5 );.unshift( 0 );say .raku; # OUTPUT: «Buf.new(0,1,1,2,3,5)»
In Any§
See primary documentation in context for method unshift
multi method unshift(Any: --> Array)multi method unshift(Any: --> Array)
Initializes Any
variable as empty Array
and calls Array.unshift
on it.
my ;say .unshift; # OUTPUT: «[]»say ; # OUTPUT: «[]»my ;say .unshift([1,2,3]); # OUTPUT: «[[1 2 3]]»
In IterationBuffer§
See primary documentation in context for method unshift
method unshift(IterationBuffer: 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.