iterator

operator fun <T> Enumeration<T>.iterator(): Iterator<T> (source)

Platform and version requirements: JVM

Creates an Iterator for an java.util.Enumeration, allowing to use it in for loops.

import samples.Sample
import java.util.*

fun main(args: Array<String>) {
//sampleStart
val vector = Vector<String>().apply {
    add("RED")
    add("GREEN")
    add("BLUE")
}

// iterator() extension is called here
for (e in vector.elements()) {
    println("The element is $e")
}
//sampleEnd
}