I think I saw this in Typescript, not in Kotlin, but I want to double check.
When using XML nodes, a boolean check and a cast often go together. Is there a way to make the check lead to a smart cast? In this case from Node
to Element
.
for (child in documentElement.childNodes.toList()) {
if (child.isElement) {
// Here, could smart cast `child` from Node to Element
}
}
...
val Node.isElement: Boolean
get() = nodeType == Node.ELEMENT_NODE