-
-
Save KatieBarnett/e9114f458d20e7419ecbaee1e8a624b8 to your computer and use it in GitHub Desktop.
Null Conditional Modifier
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
inline fun <T> Modifier.nullConditional( | |
argument: T?, | |
ifNotNull: Modifier.(T) -> Modifier, | |
ifNull: Modifier.() -> Modifier = { this }, | |
): Modifier { | |
return if (argument != null) { | |
then(ifNotNull(Modifier, argument)) | |
} else { | |
then(ifNull(Modifier)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment