如何在scala中使用"should be"的逻辑"OR"运算符?

Gol*_*irl 3 scala scalatest

我试图使用"应该"功能以及逻辑"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 */
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误,说"值||不是org.scalatest.matchers.Matcher [Any]的成员"

有人可以帮我吗 先感谢您..

Lee*_*Lee 10

从错误消息中,它看起来像String.value.size should be (8)返回一个org.scalatest.matchers.Matcher没有成员的实例||.根据这个你应该or用于分离,例如

String.value.size should (be (8) or be (0))
Run Code Online (Sandbox Code Playgroud)