Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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..

like image 274
Goldengirl Avatar asked Apr 20 '16 13:04

Goldengirl


1 Answers

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))
like image 92
Lee Avatar answered Nov 14 '22 04:11

Lee