blob: 7a29b80e8ddf9d8099fdd9745a836e5c6616df5b (
plain) (
tree)
|
|
object Test extends Application {
class Test(n: Int) extends Iterable[Int] {
private var i = 0
def elements = new Iterator[Int] {
def hasNext = i < n
def next =
if (hasNext) { val v = i; i += 1; v }
else throw new IndexOutOfBoundsException("empty iterator")
}
}
val x = new Test(10)
println(x.isEmpty)
println(x.mkString(","))
}
|