Skip to content

Instantly share code, notes, and snippets.

@fahadsiddiqui
Created March 22, 2017 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fahadsiddiqui/b530a093a643f489a9a661606d479f30 to your computer and use it in GitHub Desktop.
Save fahadsiddiqui/b530a093a643f489a9a661606d479f30 to your computer and use it in GitHub Desktop.
Scala case pattern match error in case of Option[String] [Solution]
def foo(args: Any*) = {
args.flatMap {
case str: String if str.isEmpty => None
case str: String => Some(str)
case Some(x: String) if x.isEmpty => None
case Some(x: String) => Some(x)
}.mkString(", ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment