Cuando invoco + en 2 obtengo un Int atrás, pero cuando se hace usando el método explícito, llamo I get Double en su lugar.Scala operator oddity
scala> 2+2
res1: Int = 4
scala> 2.+(2)
res2: Double = 4.0
Parece que. +() Se invoca implícitamente convertida en doble.
scala> 2.+
<console>:16: error: ambiguous reference to overloaded definition,
both method + in class Double of type (x: Char)Double
and method + in class Double of type (x: Short)Double
match expected type ?
2.+
^
¿Por qué es así?
Java compatibilidad: -/ – soc