Drop, Take, dropRight, takeRight, a Scala language concept

Last updated

Scala's `drop` and `take` methods typically remove or select `n` items from a collection.

This allows for quick and easy collection manipulations.

The versions with `Right` act on the right side of the collection.

assert(List(1, 2, 3).drop(2) == List(3))

assert(List(1, 2, 3).take(2) == List(1, 2))

assert(List(1, 2, 3).dropRight(2) == List(1))

assert(List(1, 2, 3).takeRight(2) == List(2, 3))

assert((1 to 5).take(2) == (1 to 2))