I found myself implementing various methods instea...
# announcements
e
I found myself implementing various methods instead
var
with custom get and set methods because they are in an interface.. isn't there any other way?
c
You don’t want to do this?
Copy code
interface Foo {
    var foo: String
        get() = ""
        set(value) {}
}
e
I recall I tried that and it was complaining
a
If its a java interface, you are out of luck
e
thanks
I expect in java to be translated as
get*
and
set*
, or?
c
You have to define the getter, because otherwise it tries to have a backing field, which it can’t in an interface.
👍 2
a
yes, but overriding a
get*
with a property gets very tricky in mixed inheritance architectures
e
uhm, so better stay with the classical approach?
c
If you can’t overload the get and set methods in java (which I haven’t tried), and that’s something you need. then yes, I would say you’re stuck with having actual get and set methods in Kotlin.
e
ok
thanks
a
e
smart, I almost forgot about the possibility to rename them