How to convert array of string to list of integers using val. I am using below code to do this
object ArraytoListobj {
def main(args :Array[String]) {
val intList :List[Int] = args.toList
println(intList)
}
}
When trying to compile the programme, I am getting below error.
scala:3: error: type mismatch;
found : List[String]
required: List[Int]
val intList :List[Int] = args.toList
one error found
args.map(_.toInt).toListbut it will throw if anyStringcontains non-digit characters.