This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Description
Is your topic request related to a problem? Please describe.
There is already some information about iterator in cycles and strings topics. Arrays (that ofc related to iterators) is very important structure to explain.
Describe the solution you'd like
I'd like to tell more about iterator (how it works in order to OOP in Kotlin). And make kinda example:
class Element(var string: String, var next: Element?)
class Elements(private var initial: Element) : Iterable<Element> {
private var first: Element = initial
fun iterator(): Iterator {
return object : Iterator {
private var current: Element = first
override fun hasNext(): Boolean {
return current.next != null
}
override fun next(): Element {
val output = current
current = current.next ?: throw IllegalStateException()
return output
}
}
}
}
Also example with own range realization.
What place topic should have? Why?
It should be after nullable and throwables topics.