Last active
April 26, 2018 11:02
-
-
Save ditn/364e40d982cb0b713941008129e43351 to your computer and use it in GitHub Desktop.
Generic ternary function
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
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