Scala: how to understand the flatMap method of Try?
问题 The flatMap method of the Success is implemented like this: def flatMap[U](f: T => Try[U]): Try[U] = try f(value) catch { case NonFatal(e) => Failure(e) } I kinda understand what this method is doing, it helps us to avoid writing a lot of catching code. But in what sense is it similar to the regular flatMap? A regular flatMap takes a sequence of sequences, and put all the elements into one big "flat" sequence. But the flatMap method of Try is not really flattening anything. So, how to