Normally if I am reading a line of input from stdin that looks like "100 200" I can store them both as ints with this line:
val Array(a, b) = readLine.split(" ").map(_.toInt);
But what if a is an integer and b is a string?
You cannot store values of different types into an homogeneous container such as an Array.
If you know the cardinality, just store them in separate variables.
val input = "100 foo"
val Array(a, b) = input.split(" ")
val p1 = scala.util.Try(a.toInt)
val p2 = b
I used scala.util.Try because toInt may fail and throw an exception
Array. If you know the cardinality just put them in variables