Skip to content

Instantly share code, notes, and snippets.

@AkshayChordiya
Created July 7, 2017 04:50
Show Gist options
  • Save AkshayChordiya/596d935ef792e51525649cadd5241ff4 to your computer and use it in GitHub Desktop.
Save AkshayChordiya/596d935ef792e51525649cadd5241ff4 to your computer and use it in GitHub Desktop.
Example of takeIf function in Kotlin
val index = "Kotlin".indexOf('K').takeIf { it > 0 } ?: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment