Skip to content

Instantly share code, notes, and snippets.

@tachesimazzoca
Last active October 10, 2015 02:08
Show Gist options
  • Save tachesimazzoca/3615945 to your computer and use it in GitHub Desktop.
Save tachesimazzoca/3615945 to your computer and use it in GitHub Desktop.
Set a default value for an empty string #scala
val strings = Array("Foo", "") map { str =>
Some(str).filter(_ != "").getOrElse("Bar")
}
strings.foreach(println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment