Skip to content

Instantly share code, notes, and snippets.

@PeteGabriel
Created February 14, 2018 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeteGabriel/572627a2ed20529fe84f8db8f2822f94 to your computer and use it in GitHub Desktop.
Save PeteGabriel/572627a2ed20529fe84f8db8f2822f94 to your computer and use it in GitHub Desktop.
Kotlin Ternary Operator extension
infix fun <T> Boolean.then(param: T):T? = if (this) param else null
//usage
// item.isFavorite then R.string.fav ?: R.string.unfav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment