Skip to content

Instantly share code, notes, and snippets.

@auramo
Last active August 29, 2015 13:59
Show Gist options
  • Save auramo/10447577 to your computer and use it in GitHub Desktop.
Save auramo/10447577 to your computer and use it in GitHub Desktop.
Option whenEmpty
class Jaba(option: Option[_]) { def whenEmpty(f: => Unit) { if (!option.isDefined) f } }
implicit def option2Jaba(o: Option[_]) = new Jaba(o)
val x: Option[Unit] = None
x whenEmpty { println("yeah") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment