Kotlin & Coroutines (50 Qs)•Part 3: K2 Compiler, KMP, Advanced Metaprogramming & Optimization (25 - 35)
Kotlin Delegated Properties: `by lazy`, `by Delegates.observable()`, and custom delegates.
senior LevelRxJSPerformance
In Simple Words: Delegates property getter and setter logic to an external reusable object:
by lazy { ... }: Computes the value once on first access and caches it thread-safely.by Delegates.observable(initialValue) { prop, old, new -> ... }: Triggers a callback whenever the property mutates.- Custom Delegate: Implement
ReadOnlyProperty<R, T>orReadWriteProperty<R, T>withgetValueandsetValuemethods.