Skip to content

Instantly share code, notes, and snippets.

@ditn
Last active April 26, 2018 11:02
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 ditn/364e40d982cb0b713941008129e43351 to your computer and use it in GitHub Desktop.
Save ditn/364e40d982cb0b713941008129e43351 to your computer and use it in GitHub Desktop.
Generic ternary function
fun <T> T.ternaryBuilder(
predicate: () -> Boolean,
trueFunc: T.() -> T,
falseFunc: T.() -> T
): T = if (predicate()) this.trueFunc() else this.falseFunc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment