ppoliani
ppoliani

Reputation: 4906

Scalatest call be without parenthesis

Why does the following code fails:

session.getGameId should be 10 

with this error

';' expected but integer literal found.

However this one doesn't fail

session.getGameId should be(10)

Does it have to do with the way that the apply method is called

Upvotes: 2

Views: 115

Answers (1)

kiritsuku
kiritsuku

Reputation: 53348

session.getGameId should be 10

means

(session.getGameId).should(be).(10)

whereas

session.getGameId should be(10)

means

(session.getGameId).should(be(10))

Obviously, the first one can't compile since it is not valid to call an integer literal in this position. See this question for further explanation when you can leave out parentheses and dots in Scala.

Upvotes: 2

Related Questions