Created
February 24, 2018 00:00
-
-
Save AndyG/335283bf51eb54e822c9e359ffe5ce6a to your computer and use it in GitHub Desktop.
Basic Abstract Syntax Tree Node
This file contains 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
open class Node { | |
private var children: MutableCollection<Node>? = null | |
fun getChildren(): Collection<Node>? = children | |
fun hasChildren(): Boolean = children?.isNotEmpty() == true | |
fun addChild(child: Node) { | |
children = (children ?: ArrayList()).apply { | |
add(child) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment