July 2017
Intermediate to advanced
796 pages
18h 55m
English
drop is used to select all elements except the first n elements. It can be defined formally as follows:
def drop(n: Int): Traversable[A]
Let's see an example as follows:
// Drop the first three elementsscala> List(1,2,3,4) drop 3res8: List[Int] = List(4)
In Scala, if you want take a set of elements until a predicate is satisfied, you should use takeWhile. In the next subsection, we will see how to use takeWhile.
Read now
Unlock full access