Search code examples
functional-programmingkotlin

Take last n element in Kotlin


I have a list on which I'd like to apply some transformations, but excluding the first 2 elements. How can I do it the nicest way? Something like this:

list.reversed().take(list.size - 2)...(my transformations)

or

list.excludeFirstN(2)...(my transformations)

Solution

  • Oh, I found the drop() function.