getOrEmpty

fun Array<String>.getOrEmpty(index: Int): String

Returns an element at the given index or empty if the index is out of bounds of this string Array.

Example:

val list = arrayOf(1..5)
list.getOrEmpty(8) // ""
list[2] // 3

Since

1.1.0

See also


fun Collection<String>.getOrEmpty(index: Int): String

Returns an element at the given index or empty if the index is out of bounds of this string Collection.

Example:

val list = listOf(1..5)
list.getOrEmpty(8) // ""
list[2] // 3

Since

1.1.0

See also