public abstract class Generator<T> implements AutoClosable
Lazy, forward-only sequence produced by a function containing yield.
A generator is not a collection: it has no size, index or mutation API. Each call creates an independent cursor. Values are computed on demand; the cursor keeps its current value, not a history of the sequence. A completed or closed cursor cannot be restarted. for closes its generator on every exit, including break.
import klyn.collections
def numbers() as Generator<Int>:
yield 10
yield 20
for number in numbers():
print(number)| Modifier and Type | Member | Description |
|---|---|---|
| public abstract readonly property | currentcurrent as T |
Reads the current element without advancing the generator. |