The drop function

This is another very straightforward function. The drop function accepts an argument, ignores a number of elements from the main list, and returns a new list as a result. Take a look at the following example:

var numbers = listOf<Int>(1,2,3,4,5,4,3,8,9,10)
var newList = numbers.drop(5)
println("Drop first 5 elements")
println(newList)

The drop function drops the first five elements from the list and returns [4, 3, 8, 9, 10] as a result. The drop function has a number of other variants.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.81.201