is this a correct implementation of `.forEach` ``...
# announcements
s
is this a correct implementation of
.forEach
Copy code
inline fun forEach(action: (T?) -> Unit) {
        val iter = iterator()
        var it = iter.next()
        while(it != null) {
            action.invoke(p1 = it)
            it = iter.next()
        }
    }
a
Afaict it's not a correct implementation Iterator#next throws a NoSuchElementException if there's no element iirc, you would have to use Iterator#hasNext
s
ok