Which is best ?
((startDigit1 + 1u).toUByte()..endDigit1).toSet() as Collection<UByte>
((startDigit1 + 1u).toUByte()..endDigit1).map { it.toUByte() }
Supposing that startDigit1 + 1u
never overflows.
My IDE gives me an uncheck cast warning for the former, but I don’t know how serious it is if all values are sure to be in the 0…255 range.