What is the basic design idea behind the Scala for-loop implicit box/unboxing of numerical types?
- by IODEV
I'm trying to understand the behavior of Scala for-loop implicit box/unboxing of "numerical" types. Why does the two first fail but not the rest?
1) Fails:
scala for (i:Long <- 0 to 10000000L) {}
<console>:19: error: type mismatch;<br>
found : Long(10000000L)
required: Int
for (i:Long <- 0 to 10000000L) {}
^
2 Fails:
scala for (i <- 0 to 10000000L) {}
<console>:19: error: type mismatch;
found : Long(10000000L)
required: Int
for (i <- 0 to 10000000L) {}
^
3) Works:
scala for (i:Long <- 0L to 10000000L) {}
4) Works:
scala for (i <- 0L to 10000000L) {}