About Try#transform


I was thinking about the

  def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U]

method on Try should be named as transformWith
and then we could have both

  def transformWith[U](s: T => Try[U], f: Throwable => Try[U]): Try[U]
  def transform[U](s:T => U, f:Throwable => Throwable):Try[U]
1 Like

The current signature of transform allows you to recover from Failures and to gently fail on Successes while your proposed method can be used only to transform Success to Success and Failure to Failure.

Your signature seems to have completely different semantics and moreover looks (to me, at least) to be far less useful.

1 Like