Add isNullOrEmpty() to Array, Collection, and Map. Fixes KT-23279
This commit is contained in:
@@ -37,3 +37,9 @@ public fun <T, R> Array<out Pair<T, R>>.unzip(): Pair<List<T>, List<R>> {
|
||||
}
|
||||
return listT to listR
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if this array is null or empty.
|
||||
* @sample samples.collections.Arrays.Usage.arrayIsNullOrEmpty
|
||||
*/
|
||||
public fun Array<*>?.isNullOrEmpty(): Boolean = this == null || this.isEmpty()
|
||||
|
||||
@@ -140,6 +140,10 @@ private const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.isNotEmpty(): Boolean = !isEmpty()
|
||||
|
||||
/** Returns `true` if this map is null or empty. */
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean = this == null || isEmpty()
|
||||
|
||||
/**
|
||||
* Returns the [Map] if its not `null`, or the empty [Map] otherwise.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user