val foo: Int = 1 foo.toDouble() // ok val bar = 2.toUInt() bar.toDouble() // error!
This doesn't make sense to me. Why wouldn't UInt have
toDouble? (it also doesn't have
Every number type supports the following conversions:
- toByte(): Byte
- toShort(): Short
- toInt(): Int
- toLong(): Long
- toFloat(): Float
- toDouble(): Double
- toChar(): Char
So it should be possible. The error I get is:
Error:(11, 4) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: @InlineOnly public inline fun String.toDouble(): Double defined in kotlin.text
Is UInt not considered a number type? Or is it something else?