Created
May 31, 2014 23:44
-
-
Save dcki/ddbe82d871465838728d to your computer and use it in GitHub Desktop.
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
class Node | |
attr_accessor :children | |
def initialize | |
@children = [] | |
end | |
def to_s | |
"Node with children #{children.to_s}" | |
end | |
end | |
a = Node.new | |
a.children << Node.new | |
a.children[0].children << a | |
puts a | |
# Output: Node with children [Node with children [Node with children [...]]] | |
# (Literal ellipsis were included in output, I didn't add them.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment