score:0

Scala is a statically typed language, and in your case the type of arr is Array[_ >: Int with String]. Hence, if you give it an Int, you get a type error.

Depending on how you're using the array further in your code, I'd recommend you take a look at Either[1], since it may be helpful in keeping an Array[Either], and processing it using pattern matching differently for when it contains an Int vs String.

[1] http://danielwestheide.com/blog/2013/01/02/the-neophytes-guide-to-scala-part-7-the-either-type.html


More Query from same tag