Sam Stone
10/05/2023, 11:38 PMDegreeOffset.NINETEEN_POINT_EIGHT_DEGREES
so often. However, it is illegal to write DegreeOffset.19.8
, and I don't want to resort to `DegreeOffset.`19.8``. What is the best language construct/naming convention to use, and should this become a feature request for one? DegreeOffset._19_8
maybe? Looks wrong.hho
10/06/2023, 10:31 AMDegreeOffset.NINETEEN_EIGHT
. With autocomplete, it's not that much typing (<http://DOff.NE|DOff.NE><Tab>
).sbyrne
10/06/2023, 4:42 PMDegreeOffset._19_8
, or DegreeOffset.DO_19_8
if you really do not like leading underscores.Klitos Kyriacou
10/06/2023, 4:57 PM@JvmInline
value class DegreeOffset(val offset: float) {
init {
require(offset in arrayOf(..., 19.8, ...)
}
}
Usage: foobar(DegreeOffset(19.8))
I know floating-point numbers shouldn't be compared for exactness, but as long as all instances are literals, it should be ok.vanshg
10/06/2023, 5:28 PMresort to `DegreeOffset.`19.8``IMO, this is exactly the sort of situation that the
syntax is helpful for