takeWhile
inline
fun
BooleanArray
.
takeWhile
(
predicate
:
(
Boolean
)
->
Boolean
)
:
List
<
Boolean
>
(source)
@ExperimentalUnsignedTypes
inline
fun
ULongArray
.
takeWhile
(
predicate
:
(
ULong
)
->
Boolean
)
:
List
<
ULong
>
(source)
@ExperimentalUnsignedTypes
inline
fun
UByteArray
.
takeWhile
(
predicate
:
(
UByte
)
->
Boolean
)
:
List
<
UByte
>
(source)
@ExperimentalUnsignedTypes
inline
fun
UShortArray
.
takeWhile
(
predicate
:
(
UShort
)
->
Boolean
)
:
List
<
UShort
>
(source)
Returns a list containing first elements satisfying the given predicate .
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val chars = ('a'..'z').toList()
println(chars.take(3)) // [a, b, c]
println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e]
println(chars.takeLast(2)) // [y, z]
println(chars.takeLastWhile { it > 'w' }) // [x, y, z]
//sampleEnd
}