2016-04-20 56 views
1

我試圖用「應該」與邏輯「或」運算符沿功能(例如)如下:如何在scala中使用符合邏輯的'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 */ 

,但我得到一個錯誤說「值||不是成員org.scalatest.matchers.Matcher [Any]「

有人可以幫我在這裏。提前致謝..

+0

你不應該這樣做!你的測試需要確定性 –

回答

6

從錯誤消息,它看起來像String.value.size should be (8)返回一個org.scalatest.matchers.Matcher的實例,它沒有成員||。根據this,您應該使用or進行分離。

String.value.size should (be (8) or be (0))