Hello, World! I just stumbled upon something that ...
# announcements
b
Hello, World! I just stumbled upon something that surprised me: when using delegation to another property (new in 1.4, see https://kotlinlang.org/docs/reference/delegated-properties.html#delegating-to-another-property), it looks like the
get
of the delegated property is called at init time. So in a sense, these 2 constructs don't do the same:
Copy code
// old way: wrapped.a is called only when this.a is called
val a: Boolean get() = wrapped.a

// new way: wrapped.a is called when this.a is called but also right here at init
val a by wrapped::a
Is this correct / intended or am I missing something?
­čśÉ 1
a
Seems interesting, both would do the same. get is simply a getter method (is invoked everytime property is accessed). And the second style may have a performance penalty as using reflections...