Is there a way to override a property getter so th...
# announcements
m
Is there a way to override a property getter so that the backing field is
const
? I.e.
(FooFeature as Feature).id
uses the property getter and
FooFeature.id
uses the compile-time constant
n
I dunno, the val in Feature is implemented as a method...I don't think there's a way around that
you could make a separate const that
id
returns; JVM should inline it at runtime
b
Not possible since const is only usable on companion objects and top level values
m
@nanodeath I want to avoid additional properties. @Big Chungus
const
works on any
object
, not just companions.
b
So even without the override you couldn't declare id as string
Does it? Odd. I scould swear it wasn't working for me on class member props
My bad
m
@Big Chungus yes, it doesn’t work with
class
but with
object
as there will only ever be a single instance.
b
Ah, right. Missed the object