Scala Iterator drop() method with example
The drop() method belongs to the concrete value member of the class Abstract Iterator. It is defined in the classes Iterator and IterableOnceOps. It is utilized to move the iterator n places ahead and if n is greater than the iterator’s length, then it will throw an exception.
Method Definition : def drop(n: Int): Iterator[A]
Where, n is the number of elements to be dropped from the stated iterator.
Return Type : It returns all the elements of the stated iterator except the first n ones.
Here, the first four elements are dropped and all the elements after that are returned.