drop
Thanks for your feedback!
Was this page helpful?
Returns a list containing all elements except last n elements.
if n is negative.
import kotlin.test.* fun main() { //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 }
xxxxxxxxxx
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]
Returns a list containing all elements except last n elements.
if n is negative.
import kotlin.test.* fun main() { //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 }
xxxxxxxxxx
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]
Thanks for your feedback!