Rxjava

Kotlin's Computed Properties Are Just Methods

But don't use them to make Observables

Ronald Martin

12 minute read

Bytecode generated in Android Studio

Note: this post assumes familiarity with Java language features and conventions. RxJava familiarity is useful, but not required. I was curious today about the relationship of Kotlin’s computed properties and methods. They do very similar things, so are they implemented similarly? (Spoiler: Yes. Yes they are.) Somehow, however, I also ended up drawing some conclusions on the semantics of reactive Observable generation. Kotlin’s computed properties can be a powerful tool for expressing your program’s intent with Observables, but you should think twice before using them for that purpose.