wait, you want to force subclasses to implement a ...
# announcements
s
wait, you want to force subclasses to implement a static field?
a
companion object { abstract val name = "" }
Such that, the subclass will have to override this with their own value.
s
doesn’t really work like that
companion objects can’t be abstract
a
Yes, so this idea can’t be done in Kotlin? 😞
s
you also can’t do this in Java I don’t think
a
😂 Don’t know that, not using java that much. So how could implement this idea in Kotlin? Force the subclass to have a static val?
s
static
is not really an applicable concept in Kotlin
I don’t know if you’re coming from a C++ background or something, but you’re going to have a bad time trying to force something like this on the language
you can force, just, a normal implementation by declaring a val without a value in an interface
a
Wow, thanks for the details and that SO post. Yes, if it is not static then it is not fit our use case. Because this is some constants that related to this class before initialzation, and I don;t want to put them in the
constants
namespace.