class Subject(name: String)
subjects is a sequence of Option[Subject]
val subjects = Seq(Subject("Physics"),Subject("Maths"),None)
We have a function which returns a Option[Subject]
val target = getTarget()
//Option[Subject]
What is the idiomatic safe way of finding a Option[Type] in a sequence of Option[Type] – used-cases being
- subjects may be empty
- subjects may contain all none
- target may be None
1