Erm, sorry extension interfaces/classes*
# getting-started
m
Erm, sorry extension interfaces/classes*
u
moltendorf: No, Kotlin has extension functions/properties too. In short, delegated property is an object that pretends to be a property. In long
Copy code
val x: Int by delegate
compiles to something like this
Copy code
private val $delegate = delegate
val x: Int get() = $delegate.getValue(this, this::x)
https://kotlinlang.org/docs/reference/delegated-properties.html There is class delegation too https://kotlinlang.org/docs/reference/delegation.html
m
It took me almost four days to wrap my head around the way these work (someone pointed out delegated properties earlier, which was a solution to another thing). I don't know if it's just literally done differently in a system's language or if they just simply provide some compiler magic. But in Rust/Swift I recall implementing an interface and being able to blindly use any object of CurrentType as ImplementedType (e.g. we have to manually construct each delegate in Kotlin). Anyway, got it figured out. Thanks!
u
You're welcome