takeLastWhile

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

Returns a list containing last elements satisfying the given predicate.

Since Kotlin

1.0

Samples

import kotlin.test.*

fun main() { 
   //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
}