Say I have a val s: Option[Option[String]]. It can thus have the following values:
val s: Option[Option[String]]
Some(Some(\"foo\")) Some(None) None
Some(Some(\"foo\"))
Some(None)
None
It's a shame that flatten doesn't exist. It should.
flatten
Flatten does exist now.
As before,
s getOrElse None
(in addition to the other answers) will also do the same thing.