Skip to content

Instantly share code, notes, and snippets.

@joa
Created March 12, 2013 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joa/5141649 to your computer and use it in GitHub Desktop.
Save joa/5141649 to your computer and use it in GitHub Desktop.
implicit class Iif[T](val x: T) extends AnyVal { def iif(cond: => Boolean): Option[T] = if(cond) Some(x) else None }
"yey" iif true == true getOrElse "ney" //yey
"yey" iif true != true getOrElse "ney" //ney
val file = "index.html" iif req.uri == "/" getOrElse req.uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment