get_child feels like java
This commit is contained in:
parent
96063631d8
commit
d5e899f804
1 changed files with 2 additions and 2 deletions
4
thing.rb
4
thing.rb
|
@ -69,7 +69,7 @@ class Node
|
||||||
@children.has_key? key
|
@children.has_key? key
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_child(name)
|
def [](name)
|
||||||
@children[name]
|
@children[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ def mk_hash(sgmts, parent)
|
||||||
unless parent.has_key?(segment)
|
unless parent.has_key?(segment)
|
||||||
parent.children[segment] = mk_hash(sgmts, Node.new(segment))
|
parent.children[segment] = mk_hash(sgmts, Node.new(segment))
|
||||||
else
|
else
|
||||||
mk_hash(sgmts, parent.get_child(segment))
|
mk_hash(sgmts, parent[segment])
|
||||||
# else
|
# else
|
||||||
# hash[segment].update(mk_hash(sgmts, hash[segment]))
|
# hash[segment].update(mk_hash(sgmts, hash[segment]))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue