nestserau
11/08/2018, 4:47 PMif (f.value in from..to && !c.isEmpty)
, then it doesn’t compile saying Type interference failed
. Any other options?
fun notEmptyFieldInRange(from: UByte, to: UByte): Boolean {
for ((f, c) in fields)
if (f.value >= from && f.value <= to && !c.isEmpty)
return true
return false
}
hudsonb
11/08/2018, 5:33 PMNikky
11/08/2018, 10:35 PMf
is a UByte then you probably do not want to compare its value
(which would be Byte
)nestserau
11/09/2018, 8:16 AMf.value
is also UByte
.f
is my custom type.hudsonb
11/09/2018, 12:35 PMf.value
is a UByte
as you believe.
val f = 5u
val from = 0u
val to = 10u
if(f in from..to)
println("works")
nestserau
11/09/2018, 1:16 PMUInt
. That will work indeed. Not in case of UByte
. f.value
is really UByte
, doublechecked that.hudsonb
11/09/2018, 2:47 PMif (f.value.toUInt() in from..to && !c.isEmpty)
..
creates a UIntRange
nestserau
11/09/2018, 2:57 PM