Should produce all elements from the iterator and push them to $target.

my@array;

say (1..1000).iterator.push-all(@array); # All 1000 values are pushed

The Iterator role implements this method in terms of push-at-least. As in the case of the other push-* methods, it is mainly intended for developers implementing this role. push-all is called when assigning an object with this role to an array, for instance, like in this example:

classDNAdoesIterabledoesIterator{

has$.chain;

hasInt$!index=0;

methodnew ($chainwhere{

$chain~~/^^<[ACGT]>+$$/and

$chain.chars%%3} ) {

self.bless( :$chain );

}

methoditerator( ){self}

methodpull-one( -->Mu){

if$!index<$.chain.chars{

my$codon=$.chain.comb.rotor(3)[$!indexdiv3];

$!index+=3;

return$codon;

}else{

returnIterationEnd;

}

}

methodpush-all(Iterator:D:$target) {

for$.chain.comb.rotor(3) ->$codon{

$target.push:$codon;

}

}

};

my$b:=DNA.new("AAGCCT");

my@dna-array=$b;

say@dna-array; # OUTPUT: «[(A A G) (C C T)]␤»

The push-all method implemented pushes to the target iterator in lists of three aminoacid representations; this is called under the covers when we assign $b to @dna-array.

This is a work in progress to document Raku (formerly known as Perl 6), and
known to be incomplete.