Skip to content

Instantly share code, notes, and snippets.

@chuckg
Forked from anonymous/gist:3266828
Created August 5, 2012 19:55
Show Gist options
  • Save chuckg/3266931 to your computer and use it in GitHub Desktop.
Save chuckg/3266931 to your computer and use it in GitHub Desktop.
class TreeNode
attr_accessor :nodeType, :value, :children
def initialize(nodeType, value, children=[])
raise Exception unless children.is_a?(Array)
@nodeType = nodeType
@value = value
@children = children
end
end
tn = TreeNode.new("Answer", "child value")
tnRoot = TreeNode.new("Decision", "Root", [tn])
tnRoot.children.each do |node|
puts node.value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment