summaryrefslogtreecommitdiff
path: root/test/files/run/iterables.scala
blob: 7a29b80e8ddf9d8099fdd9745a836e5c6616df5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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(","))
}