I am trying to split a string that is input by the user. My code looks similar to the following:
val aList = Array(5, {Array<String>(2){ " " }})
aList[0] = ArrayList(input.nextLine().split(" ")) // `split` returns a List
But this results in the following error:
error: type inference failed. Expected type mismatch: inferred type is ArrayList<String!> but Array<String> was expected.
After some digging around I found that the T! operator means T or T?. How can I cast ArrayList<String!> to Array<String>?