<Can I get a syntax like Measure&lt;DistanceUnit&g...
# stackoverflow
u
Can I get a syntax like Measure&lt;DistanceUnit&gt;.ZERO in Kotlin? I'm working in a larger codebase, there is a Distance class which had a companion object with a ZERO property, used as Distance.ZERO. I am now introducing a unit system: Distance will now be typealiased to Measure. So: On the one hand, unfortunately the companion object is shared between all Measures regardless of template parameter, so I wouldn't know what type to give ZERO. On the other hand, an extension property like val Distance.ZERO: Distance get() = Distance(0.0, DistanceUnit.METERS)...