Last active
November 7, 2018 03:49
-
-
Save hilfritz/2401230f5cd4435067437c2b8bb9eff2 to your computer and use it in GitHub Desktop.
Kotlin if else equivalent
This file contains hidden or 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
| property?.let { | |
| //if 'property' is not null | |
| fancyPrint(it) //'it' refers to 'property' | |
| } ?: run { | |
| //'else' clause - property is null | |
| showError() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment