The duplicate() method belongs to the concrete value member of the class iterator. It generates a duplicate of the iterator which will iterate over the alike order of values. The duplicate iterators are said to be equal if they are put at the identical element.
- Method Definition:
def duplicate: (Iterator[A], Iterator[A])
- Return Type:
It returns a pair of iterators.
(non-empty iterator, non-empty iterator)
Here, the stated iterator is non-empty so, two non-empty iterators are created.
(empty iterator, empty iterator)
Here, the stated iterator is empty so, two empty iterators are created.