The program is:
object Hello extends App {
val a: List[Int] = List(1, 3, 4, 5, 8, 10, 11, 22, 33)
for (i <- 0 to 11)
println(a(i))
}
The Output is:
1
3
4
5
8
10
11
22
33
java.lang.IndexOutOfBoundsException: 9 // continues as a long error message.
How did it not detect at the compile time that the index was going to be out of bound? Aren't compiled languages supposed to do this? If no, could you please share what is included in the compile time checks and what's not?
As a newbie, I always hear that, compiled languages are great that they find errors at compile time thus are more robust.