Specific case that I have encountered. How to handle effectively Scala Option of Collections of specific type?
As mentioned in one of the answers, using Option
of Collection is not optimal and it's better to represent the absence of values with empty collection. But, this signature is force of me by a wacky external service.
So, and example. I have:
val myData = Option[Seq[MyObj]]
case class MyObj(name: String)
I want to map myData
to some other type which is an Seq of NewObj
.
val newData: Seq[NewObj] = myData.XXX
What is the best practice to map myData
to different object?