Adam S
01/17/2023, 6:46 PM0u
? At the moment Kotlin doesn’t know which unsigned type to use, and errors with Overload resolution ambiguity
.fun operation(uByte: UByte?): Unit = operation(uByte.toString())
and while there’s still an error with operation(0u)
, at least it can be specified with operation(uLong = 0u)
Laertes Moustakas
01/17/2023, 7:44 PM0u.javaClass.typeName
outputs kotlin.UInt
, yet it still prints this error on operation(0u)
. You can use parameter names like you did with operation(uLong = 0u)
, but you can also call one of the "casting" methods, such as operation(0u.toUInt())
, operation(0u.toUShort())
, etc.
As for a generic method matching all unsingned types, I'm not sure how. Looking at the API, it doesn't seem like they extend any other types like Number
, they only implement Comparable<T>
.Adam S
01/18/2023, 9:30 AM