Skip to content

Instantly share code, notes, and snippets.

@BenFradet
Created May 17, 2017 16:14
Show Gist options
  • Save BenFradet/414e31933471316e7b7a2424d2a2efd0 to your computer and use it in GitHub Desktop.
Save BenFradet/414e31933471316e7b7a2424d2a2efd0 to your computer and use it in GitHub Desktop.
val l = List(Success(true), Success(false), Failure(new Exception("a")))
val good = l.filter { result: Validation[Exception, Boolean] =>
result match {
case Success(r) => r
case Failure(_) => false
}
}
// List(Success(true))
val bad = good.flatMap { r =>
r match {
case Failure(m) => Some(m)
case _ => None
}
}
// always empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment