Suppose I've got a function foo:Int => Try[Int]
and I need to call it with retries. That is, I need to call it till it returns Success
at most k
times.
I am writing a function retry
like that:
def retry(k: retries)(fun: Int => Try[Int]): Try[Int] = ???
I want retry
to return either Success
or the last Failure
. How would you write it ?