What is the idiomatic way of applying the function A => Try[B] to List[A] and returns either the first successful result of Some[B] (it is short-circuited), or if all else fails, returns None
I want to do something like this:
val inputs: List[String] = _ def foo[A, B](input: A): Try[B] = _ def main = { for { input <- inputs } foo(input) match { case Failure(_) => // continue case Success(x) => return Some(x) //return the first success } return None // everything failed }
source share