如何在 Scala 中使用 'OR' 与 "should be" 的逻辑运算符?
How to use the logical 'OR' operator with "should be" in scala?
我试图将 "should be" 函数与逻辑 "OR" 运算符一起使用,如下所示(例如):
def String(x :Integer) :Integer ={
/*----------------
-----------------*/
return value;
}
String.value.size should be (8) || String.value.size should be (0) /*that is anything other than the value 8 or 0 should cause a false and the program should start execution */
但我收到一条错误消息 "value || is not a member of org.scalatest.matchers.Matcher[Any]"
有人可以帮助我吗?提前谢谢你..
从错误消息来看,它看起来像 String.value.size should be (8)
returns org.scalatest.matchers.Matcher
的一个实例,它没有成员 ||
。根据 this 你应该使用 or
进行分离,例如
String.value.size should (be (8) or be (0))
我试图将 "should be" 函数与逻辑 "OR" 运算符一起使用,如下所示(例如):
def String(x :Integer) :Integer ={
/*----------------
-----------------*/
return value;
}
String.value.size should be (8) || String.value.size should be (0) /*that is anything other than the value 8 or 0 should cause a false and the program should start execution */
但我收到一条错误消息 "value || is not a member of org.scalatest.matchers.Matcher[Any]"
有人可以帮助我吗?提前谢谢你..
从错误消息来看,它看起来像 String.value.size should be (8)
returns org.scalatest.matchers.Matcher
的一个实例,它没有成员 ||
。根据 this 你应该使用 or
进行分离,例如
String.value.size should (be (8) or be (0))