stdlib: Introduced Array<T>?.orEmpty() in JVM-stdlib

This commit is contained in:
Denis Zharkov
2014-11-04 12:01:18 +04:00
committed by Andrey Breslav
parent 73ca75cc0b
commit da5164acd8
2 changed files with 17 additions and 0 deletions
@@ -35,3 +35,6 @@ public fun ByteArray.toString(charset: Charset): String = String(this, charset)
[Intrinsic("kotlin.collections.copyToArray")] public fun <reified T> Collection<T>.copyToArray(): Array<T> =
throw UnsupportedOperationException()
/** Returns the List if its not null otherwise returns the empty list */
public inline fun <reified T> Array<T>?.orEmpty(): Array<T> = this ?: array<T>()