Created
March 18, 2020 21:41
-
-
Save Nilzor/9656d9b99cfcac1c80cb2d65b4ec7e5e to your computer and use it in GitHub Desktop.
Kotlin shorthands
This file contains hidden or 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 <R, A, B> withNoNulls(p1: A?, p2: B?, function: (p1: A, p2: B) -> R): R? = p1?.let { p2?.let { function.invoke(p1, p2) } } | |
fun <R, A, B, C> withNoNulls(p1: A?, p2: B?, p3: C?, function: (p1: A, p2: B, p3: C) -> R): R? = p1?.let { p2?.let { p3?.let { function.invoke(p1, p2, p3) } } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment