Can I use ULong
as a parameter in function definition in Kotlin?
My code looks like below:
import androidx.compose.ui.graphics.Color
fun EColor(value: ULong) = Color(value)
val Red700 = EColor(0xffdd0d3c)
Then I got an error looks like:
Conversion of signed constants to unsigned ones is prohibited
If I call val Red700 = Color(0xffdd0d3c)
, then it works fine.
So how come I got this error?
CodePudding user response:
There are unsigned literals in Kotlin. You write them by adding a u
or U
suffix:
val Red700 = EColor(0xffdd0d3cU)
You can also call toULong
:
val Red700 = EColor(0xffdd0d3c.toULong())