3748507ac1
+JDK was not very helpful
35 lines
673 B
Plaintext
35 lines
673 B
Plaintext
import java.util.Enumeration
|
|
|
|
inline fun <T> java.util.Enumeration<T>.iterator() = object: Iterator<T> {
|
|
override val hasNext: Boolean
|
|
get() = hasMoreElements()
|
|
|
|
override fun next() = nextElement()
|
|
}
|
|
|
|
fun a(e : java.util.Enumeration<Int>) {
|
|
for (i in e) {
|
|
i : Int
|
|
}
|
|
}
|
|
|
|
fun <T : Any> T?.iterator() = object {
|
|
var hasNext = this@iterator != null
|
|
private set
|
|
|
|
fun next() : T {
|
|
if (hasNext) {
|
|
hasNext = false
|
|
return this@iterator.sure()
|
|
}
|
|
throw java.util.NoSuchElementException()
|
|
}
|
|
}
|
|
|
|
fun main(args : Array<String>) {
|
|
val i : Int? = 1
|
|
for (x in i) {
|
|
System.out?.println(x)
|
|
}
|
|
}
|