mzgreen
06/11/2019, 1:40 PMval foo = 0x1u
it's treated as Int
.
Is there a way to make it something else without providing a type? For example:
val foo: UByte = 0x1u
when(foo) {
0x1u -> {} // doesn't work because 0x1u is treated as an Int
}
I can do 0x1.toUByte()
but it's ugly. Is there maybe something like 0x1ub
suffix or sth like that?Ruckus
06/11/2019, 1:57 PMInt
(or UInt
with u
suffix). it's the same reason val x = 5
doesn't create a Byte
unless you specify..toUBute()
on the literal, you could try using .toUIint()
on foo to see if you like that more.
val foo: UByte = 0x1u
when (foo.toUInt()) {
0x1u -> ...
}
mzgreen
06/11/2019, 2:06 PMRuckus
06/11/2019, 2:12 PM