compared with
Key
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
{jet}
val l = 1.long 1.toLong() + 3 // Long + Int => Long
{jet}

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:
{jet}
val list = list(1.long, 100000000000, 2.long)
val list = list(1.toLong, 100000000000, 2.toLong)
{jet}

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