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