Trying to convert List[String] into List[Int] based on a Map.
However if the key does not exist I will get a null pointer exception.
How to handle that?
val strList = ["a","b","not exist in map" ]
val myMap = Map(
"a" -> 1,
"b" -> 2
)
var myList = new ListBuffer[Int]()
strList.foreach(k =>
myList += myMap(k)
)
myList.toList