Erroneous fix reverted. Test added

This commit is contained in:
Andrey Breslav
2011-10-24 11:34:07 +04:00
parent 2010d770b5
commit 292a41ec15
2 changed files with 13 additions and 6 deletions
@@ -0,0 +1,13 @@
trait Iterator<out T> {
fun next() : T
val hasNext : Boolean
fun <R> map(transform: fun(element: T) : R) : Iterator<R> =
object : Iterator<R> {
override fun next() : R = transform(<!NO_THIS!>this@map<!>.next())
override val hasNext : Boolean
// There's no 'this' associated with the map() function, only this of the Iterator class
get() = <!NO_THIS!>this@map<!>.hasNext
}
}