Scala Option Type Example

Run Settings
LanguageScala
Language Version
Run Command
object Main extends App { def getLifeExpectancy(in: Option[Int]): Option[Double] = in match { case Some(data) => Some(data + 45) case None => None } val listOfAges = List(Some(67), None, Some(15), Some(33)) print(listOfAges.flatMap(getLifeExpectancy).sum) }
Editor Settings
Theme
Key bindings
Full width
Lines