compared with
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (11)

View Page History

Every number type supports the following conversions:
* {{byte {{toLong() : Byte}}
* {{short {{toShort() : Short}}
* {{int {{toInt() : Int}}
* {{long {{toLong() : Long}}
* {{float {{toFloat() : Float}}
* {{double {{toDouble() : Double}}
* {{char {{toChar() : Char}}

Absence of implicit conversions is rarely noticeable because one can use literals almost freely cause the type is inferred from the context, and arithmetical operations are _overloaded_ for appropriate conversions, for example
val l = 1.long 1.toLong() + 3 // Long + Int => Long

There're no "L"-tagged or otherwise tagged literals. In case of ambiguity, one should use explicit conversions to specify a type for a literal:
val list = list(1.long, 100000000000, 2.long)
val list = list(1.toLong, 100000000000, 2.toLong)

if (c !in '0'..'9')
throw IllegalArgumentException("Out of range")
return c.toInt() - '0'.int '0'.toInt() // Explicit conversions to numbers