Skip to content

Instantly share code, notes, and snippets.

@machisuji
Created March 11, 2011 07:03
Show Gist options
  • Save machisuji/865561 to your computer and use it in GitHub Desktop.
Save machisuji/865561 to your computer and use it in GitHub Desktop.
How should you do it?
val msg: Option[String] = flash.get("msg")
// Do it like this?
$(".flashMessage") { node =>
if (msg.isDefined) {
node.text = msg.get
} else node.hide()
}
// Or like this?
$(".flashMessage") { node =>
msg match {
case Some(text) => node.text = text
case _ => node.hide()
}
}
// Or like this?
$(".flashMessage") { node =>
msg.map(node.text = _).getOrElse(node.hide())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment