-
-
Save lmller/aecd43c31baca2e427d4ba7c01c6fd93 to your computer and use it in GitHub Desktop.
Useful to explain the differences of the three approaches.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun printString(string: String) = println(string) | |
/** | |
* Prints successfully | |
*/ | |
Observable.just("Test string") | |
.doOnNext{ printString(it) } | |
.subscribe() | |
/** | |
* Prints successfully | |
*/ | |
Observable.just("Test string") | |
.doOnNext(this::printString) | |
.subscribe() | |
/** | |
* Does not print | |
*/ | |
Observable.just("Test string") | |
.doOnNext { this::printString } | |
.subscribe() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compare the decompiled versions (I created a
Test
class and atest
function to do decompile)://doesn't work
check the `call method of the "doesn't work" example - a function is created but never invoked