Last active
October 10, 2015 02:08
-
-
Save tachesimazzoca/3615945 to your computer and use it in GitHub Desktop.
Set a default value for an empty string #scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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