what would be the underlying difference between ``...
# getting-started
h
what would be the underlying difference between
Copy code
val self = this
and
Copy code
val self get() = this
is the latter more expensive for no reason? are they the same?
d
The latter doesn't create a member field.
h
ergo you can use it in things like interfaces, but are there other advantages? does it have no disadvantages?
d
Less memory? Can be inlined?
No disadvantages I can think of.
k
Keep in mind that the second one evaluates the expression every time, the first one only once. No different in this exact case though.
👍 3
d
Ah, wasn't thinking about the general case.