Scala-了解两种类型的折痕

时间:2019-07-18 09:48:01

标签: scala types fold either

我正在尝试了解一个折叠示例。

val rowStream: Stream[IO, Rows] = ...

rowStream.fold(Right(()): Either[RowError, Unit]) {
    case (Right(_), b) =>
        // completely succeed here
        //b.rows... etc
    case (Left(_), _) =>
        // Fail with Left(RowError)
}
  1. case (Right(_), b) =>中,b是什么?难道不应该只是通过Right()吗?以及如何允许b通过案件?

  2. 我是说Right(())传递的fold是折叠初始值,设置为单位的Right吗?

0 个答案:

没有答案