The iterator routine

Combined from primary sources listed below.

In class Any ( Type/Any )§

See primary docmentation in context for method iterator.

method iterator§

multi method iterator(Any:)

Returns the object as an iterator after converting it to a list. This is the function called from the for statement.

.say for 3; # OUTPUT: «3␤»

Most subclasses redefine this method for optimization, so it's mostly types that do not actually iterate the ones that actually use this implementation.

In role Iterable ( Type/Iterable )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(--> Iterator:D)

Method stub that ensures all classes doing the Iterable role have a method iterator.

It is supposed to return an Iterator.

say (1..10).iterator;

In class Mu ( Type/Mu )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(--> Iterator)

Coerces the invocant to a list by applying its .list method and uses iterator on it.

my $it = Mu.iterator;
say $it.pull-one# OUTPUT: «(Mu)␤»
say $it.pull-one# OUTPUT: «IterationEnd␤»

In class Seq ( Type/Seq )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(Seq:D:)

If the Seq is not cached, returns the underlying iterator and marks the invocant as consumed. If called on an already consumed sequence, throws an error of type X::Seq::Consumed.

Otherwise returns an iterator over the cached list.

In class RaceSeq ( Type/RaceSeq )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(RaceSeq:D: --> Iterator:D)

Returns the underlying iterator.

In class Junction ( Type/Junction )§

See primary docmentation in context for method iterator.

method iterator§

multi method iterator(Junction:D:)

Returns an iterator over the Junction converted to a List.

In role PositionalBindFailover ( Type/PositionalBindFailover )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(PositionalBindFailover:D:) { ... }

This method stub ensure that a class implementing role PositionalBindFailover provides an iterator method.

In class HyperSeq ( Type/HyperSeq )§

See primary docmentation in context for method iterator.

method iterator§

method iterator(HyperSeq:D: --> Iterator:D)

Returns the underlying iterator.