Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 25, 2020 16:32
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 dkomanov/4bb0cce1d31b4f8145c088057306ff13 to your computer and use it in GitHub Desktop.
Save dkomanov/4bb0cce1d31b4f8145c088057306ff13 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-3] multiple transformations
def rpcCall: Future[String] = ???
rpcCall
.map(_.split('_'))
.filter(_.length < 4)
.map {
case Array(single) => single
case Array(first, second@_) => first
case Array(first@_, second, third@_) => third
case _ => ""
}
.map(value => s"<p>$value</p>")
.recoverFilter("<p>invalid</p>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment