Option orElse

orElse returns the original Option if not None, or returns the provided Option as an alternative in that case:
def orElse[B >: A](ob: => Option[B]): Option[B] = this map (Some(_)) getOrElse ob

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala snippets
Cosmo
Sign Up Now
or Subscribe for future quizzes