Last active
May 30, 2018 02:50
-
-
Save nwillc/e17f8213c6fdff3287083c8c6f475dd1 to your computer and use it in GitHub Desktop.
First attempt at forEach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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