In Nil§

See primary documentation in context for method prepend

method prepend(*@)

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

In IterationBuffer§

See primary documentation in context for method prepend

method prepend(IterationBuffer:D: IterationBuffer:D $other --> IterationBuffer:D)

Adds the contents of the other IterationBuffer at the beginning of the IterationBuffer, and returns the updated invocant. Available as of the 2021.12 release of the Rakudo compiler.

In role Buf§

See primary documentation in context for method prepend

method prepend$elems )

Inserts elements at the beginning of the buffer.

my $ = Buf.new11235 );
$.prepend0 );
say $.raku# OUTPUT: «Buf.new(0,1,1,2,3,5)␤»

The difference from method unshift is that if you prepend a single array or list argument, prepend will flatten that array / list, whereas unshift prepends the list / array as just a single element.

In Array§

See primary documentation in context for routine prepend

sub prepend(\array|elems)
multi method prepend(Array:D: \values)
multi method prepend(Array:D: **@values is raw)

Adds the elements from LIST to the front of the array, modifying it in-place.

Example:

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

The difference from method unshift is that if you prepend a single array or list argument, prepend will flatten that array / list, whereas unshift prepends the list / array as just a single element.

In Any§

See primary documentation in context for method prepend

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

Called with no arguments on an empty variable, it initializes it as an empty Array; if called with arguments, it creates an array and then applies Array.prepend on it.

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