Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Array<out T>.drop(n: Int): List<T>
fun ByteArray.drop(n: Int): List<Byte>
fun ShortArray.drop(n: Int): List<Short>
fun IntArray.drop(n: Int): List<Int>
fun LongArray.drop(n: Int): List<Long>
fun FloatArray.drop(n: Int): List<Float>
fun DoubleArray.drop(n: Int): List<Double>
fun BooleanArray.drop(n: Int): List<Boolean>
fun CharArray.drop(n: Int): List<Char>
fun <T> Iterable<T>.drop(n: Int): List<T>
@ExperimentalUnsignedTypes fun UIntArray.drop(
    n: Int
): List<UInt>
@ExperimentalUnsignedTypes fun ULongArray.drop(
    n: Int
): List<ULong>
@ExperimentalUnsignedTypes fun UByteArray.drop(
    n: Int
): List<UByte>
@ExperimentalUnsignedTypes fun UShortArray.drop(
    n: Int
): List<UShort>

Returns a list containing all elements except first n elements.

import kotlin.test.*

fun main(args: Array<String>) {
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]


IllegalArgumentException - if n is negative.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.