Does anyone know why `kotlin.Number` is an abstrac...
# announcements
r
Does anyone know why
kotlin.Number
is an abstract class, rather than an interface?
t
Becuase it holds a value I reckon, would be kind of awkward to have an intreface backing data types.
e
No. It is purely abstract. Mostly, it is just a Java legacy in its design. But it is somewhat logical in the sense that being a number is pretty exclusive property. It is hard to imagine something being some other kind of entity and also serve its double-duty as a number.
(everything else about its design is quite illogical, though)
r
Yeah..
I'm looking at possibly porting this to use inline classes, but obviously inline classes can only implement interfaces, not extend abstract classes
at a first glance I think you can get the performance characteristics of what's called the "native decimal" in the benchmarks, but with the nicer API of the Immutable/MutableDecimal classes
It was just a curiosity I came across though, it doesn't have to extend Number, I just thought it was a bit strange. Thanks for the confirmation 🙂
k
Just don't extend it, the
Number
class is almost completely useless anyway.