Goldengirl
Goldengirl

Reputation: 967

How to use the logical 'OR' operator with "should be" in scala?

I was trying to use the "should be" function along with the logical "OR" operator as follows (for example) :

 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 */

But I get an error saying "value || is not a member of org.scalatest.matchers.Matcher[Any]"

Can somebody help me here. Thank you in advance..

Upvotes: 8

Views: 2596

Answers (1)

Lee
Lee

Reputation: 144206

From the error message, it looks like String.value.size should be (8) returns an instance of org.scalatest.matchers.Matcher which does not have a member ||. According to this you should use or for disjunction e.g.

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

Upvotes: 18

Related Questions