Skip to content

Commit

Permalink
Add single value candidates for Array.unshift
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 1, 2015
1 parent a10ec97 commit 469d463
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/Array.pm
Expand Up @@ -548,11 +548,22 @@ my class Array { # declared in BOOTSTRAP
self
}

multi method unshift(Array:D: Slip \value) {
self!ensure-allocated();
self!prepend-list(value)
}
multi method unshift(Array:D: \value) {
self!ensure-allocated();
nqp::unshift(
nqp::getattr(self, List, '$!reified'),
nqp::assign(nqp::p6scalarfromdesc($!descriptor), value)
);
self
}
multi method unshift(Array:D: **@values is raw) {
self!ensure-allocated();
self!prepend-list(@values)
}

multi method prepend(Array:D: \value) {
if nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable)) {
self!ensure-allocated();
Expand Down

0 comments on commit 469d463

Please sign in to comment.