sonolus.script.iterator¶
SonolusIterator
¶
Base class for Sonolus iterators.
This class is used to define custom iterators that can be used in Sonolus.py.
Inheritors must implement the next method,
which should return a Maybe[T].
Use an iterator only once: in one for loop, in one call to next(), or by passing it once to another iterator
consumer.
Usage
class MyIterator(Record, SonolusIterator):
def next(self) -> Maybe[T]:
...
maybe_next(iterator: Iterator[T]) -> Maybe[T]
¶
Get the next item from an iterator as a Maybe.
The iterator must be a SonolusIterator instance.