Whats the most idiomatic way to extend a primitive...
# announcements
j
Whats the most idiomatic way to extend a primitive type in kotlin? For example in the context of an Android app, I want to build a type
Force
from
Double
which represents a force value converted to the appropriate unit (lbs/kg) based on user preferences. The type would encapsulate the conversion logic
1
c
I would just use an
inline class
(the new syntax is
@JvmInline value class
). Alternatively, take a look at this: https://github.com/kunalsheth/units-of-measure
1