I read about implicit conversions between different types of value classes. The book "Programming in Scala" states:
[...] an instance of a class scala.Intautomatically expands (by implicit conversion) into an instance of the class scala.Longwhen required.
(chapter 11.1 - Scala Hierarchy)
What does “required” mean in this case? How can this be made "visible"? I assumed:
scala> var i = Int.MaxValue
i: Int = 2147483647
I expected i: Long = 2147483648to add 1.
scala> i = i + 1
i: Int = -2147483648
I did not expect to see an overflow.
source
share