We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa3607c commit 8c5867eCopy full SHA for 8c5867e
library/src/scala/collection/IndexedSeqView.scala
@@ -26,13 +26,12 @@ object IndexedSeqView {
26
private[this] var current = 0
27
override def knownSize: Int = self.size - current
28
def hasNext = current < self.size
29
- def next(): A = try {
30
- val r = self.apply(current)
31
- current += 1
32
- r
33
- } catch {
34
- case _: IndexOutOfBoundsException => throw new NoSuchElementException("last of empty iterator")
35
- }
+ def next(): A =
+ if (hasNext) {
+ val r = self.apply(current)
+ current += 1
+ r
+ } else Iterator.empty.next()
36
}
37
38
/** An `IndexedSeqOps` whose collection type and collection type constructor are unknown */
0 commit comments