Skip to content

Instantly share code, notes, and snippets.

@nwillc
Last active May 30, 2018 02:50
Show Gist options
  • Save nwillc/e17f8213c6fdff3287083c8c6f475dd1 to your computer and use it in GitHub Desktop.
Save nwillc/e17f8213c6fdff3287083c8c6f475dd1 to your computer and use it in GitHub Desktop.
First attempt at forEach
fun NodeList.forEach(block: Node.() -> Unit) {
for (i in 0 .. (length - 1)) {
item(i).block()
}
}
// And used it like...
nodelist.forEach {
if (it.nodeType == Node.ELEMENT_NODE) {
return it
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment