Last active
September 14, 2021 20:53
-
-
Save petitJAM/62141534a0b672bc4526234843791920 to your computer and use it in GitHub Desktop.
Kotlin `let` `else`
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
val foobar: Foobar? = ... | |
foobar?.let { /* foobar is not null */ } ?: run { /* foobar is null */ } | |
// this might be cool except for the back ticks ` | |
fun <T, R> T.`else`(block: T.() -> R) = run(block) | |
foobar?.let { /* foobar is not null */ } ?: `else` { /* foobar is null */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is stupid, don't do this