我对Scala Test比较陌生,所以我查阅了文档来学习如何测试Either
值。
我按照指示进行了复制,就像这样:
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
class EitherTest extends AnyFlatSpec with EitherValues {
val either: Either[Exception, Int] = Right(42)
either.right.value should be > 1
}
这种实现方式行不通,我遇到了语法错误。我做错了什么?
错误:
错误:(9,22)value不是Int的成员,either.right.value应该是>1
错误:(9,29)未找到:value,either.right.value应该是>1 - Hannes 14小时前
Error:(9, 22) value should is not a member of Int either.right.value should be > 1 Error:(9, 29) not found: value be either.right.value should be > 1
- Hannesval either = Right(42)
- sinanspdclass EitherTest extends AnyFlatSpec with EitherValues with Matchers
)。 - Marth