Apologies if this is obvious but I am new to scala and I am getting two unexpected behaviors with the following code:
Seq(1, "a", 2, "b") map {
case i: Int => i+1
}
1) I would have expected to get back a collection where the strings are unchanged and the numbers are incremented by 1 but instead I get an error.
2) I believe the case i: Int => i + 1 syntax represents a partial function which is defined for Ints. But it seems map takes a total function, so why does this even compile? Wouldn't it be better for the compiler to help me out? It is always better to move runtime exceptions to compile time exceptions.