getOrNull
Returns the sub-array from the given range if exist otherwise return a null.
Example:
arrayOf(1..10).getOrNull(0..4)!! // [1, 2, 3, 4, 5]
arrayOf(1..10).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(0..4)!! // [1, 2, 3, 4, 5]
byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
charArrayOf('a'..'z').getOrNull(0..4)!! // ['a', 'b', 'c', 'd', 'e']
charArrayOf('a'..'c').getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(0..4)!! // [1, 2, 3, 4, 5]
shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
intArrayOf(1..10).getOrNull(0..4)!! // [1, 2, 3, 4, 5]
intArrayOf(1..10).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
longArrayOf(1..10L).getOrNull(0..4)!! // [1L, 2L, 3L, 4L, 5L]
longArrayOf(1..10L).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f)
.getOrNull(0..4)!! // [1.0f, 2.0f, 3.0f, 4.0f, 5.0f]
floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f)
.getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0).getOrNull(0..4)!!
// [1.0, 2.0, 3.0, 4.0, 5.0]
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given range if exist otherwise return a null.
Example:
booleanArrayOf(true, false, true, false, true, false, true, false, true, false)
.getOrNull(0..4)!! // [true, false, true, false, true]
booleanArrayOf(true, false, true, false, true, false, true, false, true, false)
.getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
arrayOf(1..10).getOrNull(0..9 step 2)!! // [1, 3, 5, 7, 9]
arrayOf(1..10).getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(0..9 step 2)!! // [1, 3, 5, 7, 9]
byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
charArrayOf('a'..'z').getOrNull(0..9 step 2)!! // ['a', 'c', 'e', 'g', 'i']
charArrayOf('a'..'c').getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(0..9 step 2)!! // [1, 3, 5, 7, 9]
shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
intArrayOf(1..10).getOrNull(0..9 step 2)!! // [1, 3, 5, 7, 9]
intArrayOf(1..10).getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
longArrayOf(1..10L).getOrNull(0..9 step 2)!! // [1L, 3L, 5L, 7L, 9L]
longArrayOf(1..10L).getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f)
.getOrNull(0..9 step 2)!! // [1.0f, 3.0f, 5.0f, 7.0f, 9.0f]
floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f)
.getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)
.getOrNull(0..9 step 2)!! // [1.0, 3.0, 5.0, 7.0, 9.0]
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)
.getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-array from the given progression if exist otherwise return a null.
Example:
booleanArrayOf(true, false, true, false, true, false, true, false, true, false)
.getOrNull(0..9 step 2)!! // [true, true, true, true, true]
booleanArrayOf(true, false, true, false, true, false, true, false, true, false)
.getOrNull(10..14 step 2) // null
Since
1.1.0
See also
Returns the sub-listOf from the given range if exist otherwise return a null.
Example:
listOf(1..10).getOrNull(0..4)!! // [1, 2, 3, 4, 5]
listOf(1..10).getOrNull(10..14) // null
Since
1.1.0
See also
Returns the sub-list from the given progression if exist otherwise return a null.
Example:
listOf(1..10).getOrNull(0..9 step 2)!! // [1, 3, 5, 7, 9]
listOf(1..10).getOrNull(10..14 step 2) // null
Since
1.1.0