This doesn’t seem to be documented anywhere. I saw several *Array
iterators in the standard library using NoSuchElementException
. Upon searching further I found this EmptyIterator
object also using NoSuchElementException
, and as that’s what I was trying to make in the first place, I’ve copied that one (it’s internal
).
Kotlin docs sometimes lack details, but it is pretty much based on Java stdlib: Iterator (Java SE 17 & JDK 17)
Throws:
NoSuchElementException - if the iteration has no more elements
Anyway, it shouldn’t really matter that much. Most of the time we are not supposed to catch these exceptions, they are mostly for logging and debugging.