My code snippets are below
import scala.collection.mutable.HashMap
val crossingMap = new HashMap[String, Option[Long]]
val crossingData: String = ...
val time: Long = crossingMap.get(crossingData).getOrElse(0)
I get the following compile error
error: type mismatch;
found : Any
required: Long
val time: Long = crossingMap.get(crossingData).getOrElse(0)
You might want
crossingMapto containString -> Longpairs. Then you can do the following,If you really do want the
crossingMapvalues to have typeOption[Long], then you’ll have to do something like,