I want to iterate through a NodeList using a for-each loop in Java. I have it working with a for loop and a do-while loop but not for-each.
NodeList
Node
Adding the happy little kotlin version for sience:
fun NodeList.forEach(action: (Node) -> Unit) { (0 until this.length) .asSequence() .map { this.item(it) } .forEach { action(it) } }
One can then use it with nodeList.forEach { do_something_awesome() }
nodeList.forEach { do_something_awesome() }