dropLastWhile

inline fun <T> Array<out T>.dropLastWhile(predicate: (T) -> Boolean): List<T>
inline fun ByteArray.dropLastWhile(predicate: (Byte) -> Boolean): List<Byte>
inline fun ShortArray.dropLastWhile(predicate: (Short) -> Boolean): List<Short>
inline fun IntArray.dropLastWhile(predicate: (Int) -> Boolean): List<Int>
inline fun LongArray.dropLastWhile(predicate: (Long) -> Boolean): List<Long>
inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List<Float>
inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): List<Double>
inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): List<Boolean>
inline fun CharArray.dropLastWhile(predicate: (Char) -> Boolean): List<Char>
inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T>

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

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = ('a'..'z').toList()
assertPrints(chars.drop(23), "[x, y, z]")
assertPrints(chars.dropLast(23), "[a, b, c]")
assertPrints(chars.dropWhile { it < 'x' }, "[x, y, z]")
assertPrints(chars.dropLastWhile { it > 'c' }, "[a, b, c]") 
   //sampleEnd
}

inline fun UIntArray.dropLastWhile(predicate: (UInt) -> Boolean): List<UInt>
inline fun ULongArray.dropLastWhile(predicate: (ULong) -> Boolean): List<ULong>
inline fun UByteArray.dropLastWhile(predicate: (UByte) -> Boolean): List<UByte>
inline fun UShortArray.dropLastWhile(predicate: (UShort) -> Boolean): List<UShort>

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

Since Kotlin

1.3

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = ('a'..'z').toList()
assertPrints(chars.drop(23), "[x, y, z]")
assertPrints(chars.dropLast(23), "[a, b, c]")
assertPrints(chars.dropWhile { it < 'x' }, "[x, y, z]")
assertPrints(chars.dropLastWhile { it > 'c' }, "[a, b, c]") 
   //sampleEnd
}