// iteratorFunc is Iterable[SomeClass]
val iterator1 = iteratorFunc.iterator
iterator1 foreach {
...
}
val iterator2 = iteratorFunc.iterator
iterator2 foreach {
...
}
The code inside iterator1 foreach
is successfully done. But, iterator2 gives empty iterator.
Please help.
iteratorFunc
? You sayIterable
, but I suspect that itsiterator
method is broken. Is it possible thatiterator1 eq iterator2
? Because then obviously there is the bug. Iterators are consume-once only. – 0__iteratorFunc
, too. – cloud