2

Just wondering why I'm seeing the following in my REPL:

scala> 5.+(9) warning: there were 1 deprecation warning(s); re-run with -deprecation for details res18: Double = 14.0

0

1 Answer 1

5

If you follow the instructions and run the REPL using scala -deprecation, you'll see the reason for the deprecation:

scala> 1 + 1 res0: Int = 2 scala> 1.+(1) <console>:1: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. 1.+(1) ^ res1: Double = 2.0 

Tested on Scala 2.10.1

Sign up to request clarification or add additional context in comments.

3 Comments

Oh! So when the addition is performed using the 1.+(1) syntax it's converting the type to a Double as well as performing the addition, when really it should be consistent with the result of the 1 + 1 syntax and keeping the type as an Int?
Yeah, a space is required between an Int and +. Checked on Scala 2.10.3 as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.