https://kotlinlang.org logo
Title
d

Daniele Segato

06/28/2018, 7:16 AM
@diesieben07 i don't see how it's the same thing 🙂
d

diesieben07

06/28/2018, 7:17 AM
I mean in terms of duplication
u

540grunkspin

06/28/2018, 7:45 AM
In both cases you define a field and a getter. Sounds like the same thing to me 🤔
d

Daniele Segato

06/28/2018, 12:55 PM
I'm defining 2 fields and a getter here and 1 is a dummy field
u

540grunkspin

06/28/2018, 1:35 PM
Well effectively ‘myExposedData’ is a getter with the niceness added to it that you can refer to it as a regular field
You could also write just
fun getMyExposedData() {}
and that would work too but then you wouldn’t be able to refer to it as like a field
It is also a pretty common naming convention to write:
private _myData: Implementation = Implementation()
val myData: InterfaceOrSuperclass
    get() = _myData
👍 1