Many methods in the Scala collections library have a return type of Option, indicating they may fail to deliver a value. The recommended way to extract the value out of an Option is via the getOrElse method, which allows you to provide a default value in case the Option is empty.
The following program shows an example of getOrElse in action. What does it do?
val zippedLists = (List(1,3,5), List(2,4,6)).zipped val (x, y) = zippedLists.find(_._1 > 10).getOrElse(10) println(s"Found $x")
Before trying to understand what is going on here, it is useful to quickly recap the behavior of zipped via a short example: ...