Created
January 3, 2023 07:14
-
-
Save victory316/89915ea56c1c185f1e85f2dac8df7fa8 to your computer and use it in GitHub Desktop.
Useful pre-defined default Kotlin extensions.
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
/** | |
* Returns this List if it's not `null` and the empty list otherwise. | |
* @sample samples.collections.Collections.Lists.listOrEmpty | |
*/ | |
@kotlin.internal.InlineOnly | |
public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment