Minor. Use getOrElse from stdlib
This commit is contained in:
@@ -105,6 +105,3 @@ public fun <T> Collection<T>.toReadOnlyList(): List<T> =
|
||||
if (isEmpty()) Collections.emptyList() else ArrayList(this)
|
||||
|
||||
public fun <T: Any> T?.singletonOrEmptyList(): List<T> = if (this != null) Collections.singletonList(this) else Collections.emptyList()
|
||||
|
||||
public inline fun <T> List<T>.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index)
|
||||
public inline fun <T> Array<T>.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index)
|
||||
|
||||
Reference in New Issue
Block a user