Skip to content

Instantly share code, notes, and snippets.

@AndyG
AndyG / Node.kt
Created February 24, 2018 00:00
Basic Abstract Syntax Tree Node
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 {