dropLastWhile

Common
JVM
JS
Native
1.0
inline fun <T> Array<out T>.dropLastWhile(
    predicate: (T) -> Boolean
): List<T>

(source)
inline fun ByteArray.dropLastWhile(
    predicate: (Byte) -> Boolean
): List<Byte>

(source)
inline fun ShortArray.dropLastWhile(
    predicate: (Short) -> Boolean
): List<Short>

(source)
inline fun IntArray.dropLastWhile(
    predicate: (Int) -> Boolean
): List<Int>

(source)
inline fun LongArray.dropLastWhile(
    predicate: (Long) -> Boolean
): List<Long>

(source)
inline fun FloatArray.dropLastWhile(
    predicate: (Float) -> Boolean
): List<Float>

(source)
inline fun DoubleArray.dropLastWhile(
    predicate: (Double) -> Boolean
): List<Double>

(source)
inline fun BooleanArray.dropLastWhile(
    predicate: (Boolean) -> Boolean
): List<Boolean>

(source)
inline fun CharArray.dropLastWhile(
    predicate: (Char) -> Boolean
): List<Char>

(source)
inline fun <T> List<T>.dropLastWhile(
    predicate: (T) -> Boolean
): List<T>

(source)
@ExperimentalUnsignedTypes inline fun UIntArray.dropLastWhile(
    predicate: (UInt) -> Boolean
): List<UInt>

(source)
@ExperimentalUnsignedTypes inline fun ULongArray.dropLastWhile(
    predicate: (ULong) -> Boolean
): List<ULong>

(source)
@ExperimentalUnsignedTypes inline fun UByteArray.dropLastWhile(
    predicate: (UByte) -> Boolean
): List<UByte>

(source)
@ExperimentalUnsignedTypes inline fun UShortArray.dropLastWhile(
    predicate: (UShort) -> Boolean
): List<UShort>

(source)

Returns a list containing all elements except last elements that satisfy the given predicate.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val chars = ('a'..'z').toList()
println(chars.drop(23)) // [x, y, z]
println(chars.dropLast(23)) // [a, b, c]
println(chars.dropWhile { it < 'x' }) // [x, y, z]
println(chars.dropLastWhile { it > 'c' }) // [a, b, c]
//sampleEnd
}