I read about implicit conversions being done between different value class types. The book "Programming in Scala" states:
[…] an instance of class
scala.Intis automatically widened (by an implicit conversion) to an instance of classscala.Longwhen required.(Ch. 11.1 – Scala’s Hierarchy)
What does "required" mean in this case? How can one make this "visible"? I assumed:
scala> var i = Int.MaxValue
i: Int = 2147483647
I was expecting i: Long = 2147483648 if I add 1.
scala> i = i + 1
i: Int = -2147483648
I was not expecting to see an overflow.
“Required” means a method that takes a Long being passed an Int and stuff like that.
Int.+does not require a Long. For the most part, Ints behave just like Java’s primitive integer type.