The take function

This is a very straightforward function. It accepts an argument to take a number of elements from a list:

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

The number.take(5) function will return a list of the first five elements. The take function also has a number of variants.

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

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