> scala> val myI = new Iterable[Int]{def iterator = Iterator.continually(1)}
> java.lang.OutOfMemoryError: Java heap space
> at java.util.Arrays.copyOf(Arrays.java:2882) at
> <snip>
Now, is this expected behavior? I find it somewhat strange and it gets in my way.
This is just the REPL trying too hard to be helpful--it's trying to print out your new Iterable
as part of what it does when you return a value. You can either stick it in some container that doesn't print its contents or override toString
.
scala> val myI = new Iterable[Int] { def iterator = Iterator.continually(1);
| override def toString = "myI" }
myI: Iterable[Int] = myI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With