Skip to content

Instantly share code, notes, and snippets.

@jsuereth
Created September 28, 2010 19:41
Show Gist options
  • Save jsuereth/601645 to your computer and use it in GitHub Desktop.
Save jsuereth/601645 to your computer and use it in GitHub Desktop.
scala> def data(block : Int => Unit) { for(i <- 0 to 10) block(i) }
data: (block: (Int) => Unit)Unit
scala> val x = new Traversable[Int] {
| def foreach[U](f : Int => U) = {
| data( f(_) : Unit)
| }
| }
x: java.lang.Object with Traversable[Int] = line15(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> x.toList.toStream
res6: scala.collection.immutable.Stream[Int] = Stream(0, ?)
scala> x.toStream
java.lang.StackOverflowError
at $anon$1.thisCollection(<console>:6)
at scala.collection.TraversableLike$class.toStream(TraversableLike.scala:701)
at $anon$1.toStream(<console>:6)
at scala.collection.immutable.Stream.$plus$plus(Stream.scala:141)
at scala.collection.TraversableLike$class.toStream(TraversableLike.scala:701)
at $anon$1.toStream(<console>:6)
at scala.collection.immutable.Stream.$plus$plus(Stream.scala:141)
at scala.collection.TraversableLike$class.toStream(TraversableLike.scala:701)
at $anon$1.toStream(<console>:6)
at scala.collection.immutable.Stream.$plus$plus(Stream.scala:141)
at scala.collection.TraversableLike$class.toStream(TraversableLike.scala:701)
at $anon$1.toStream(<console>:6)
at scala.collection.immutable.Stream.$plus$plus(Stream.scala:141)
at scal...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment