takeLast

fun <T> Array<out T>.takeLast(n: Int): List<T> (source)
fun ByteArray.takeLast(n: Int): List<Byte> (source)
fun ShortArray.takeLast(n: Int): List<Short> (source)
fun IntArray.takeLast(n: Int): List<Int> (source)
fun LongArray.takeLast(n: Int): List<Long> (source)
fun FloatArray.takeLast(n: Int): List<Float> (source)
fun DoubleArray.takeLast(n: Int): List<Double> (source)
fun BooleanArray.takeLast(n: Int): List<Boolean> (source)
fun CharArray.takeLast(n: Int): List<Char> (source)
fun <T> List<T>.takeLast(n: Int): List<T> (source)

Returns a list containing last n elements.

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
}