Generating remove() for Iterator using same mechanism.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
class MyIterator<T>(val v: T): Iterator<T> {
|
||||
override fun next(): T = v
|
||||
override fun hasNext(): Boolean = true
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
(MyIterator<String>("") as MutableIterator<String>).remove()
|
||||
throw AssertionError()
|
||||
} catch (e: UnsupportedOperationException) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user