2

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

ppoliani
  • 4,792
  • 3
  • 34
  • 62
  • 1
    Note that more recent versions of Scalatest offer alternative forms to write `result shouldBe 10` or `result shouldEqual 10` without parenthesis. – bluenote10 May 05 '16 at 13:13

1 Answers1

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

Community
  • 1
  • 1
kiritsuku
  • 52,967
  • 18
  • 114
  • 136