假设我们有数组数组:
tree_limbs = Array.new
tree_limbs << %w(1 2 3 4 5 7)
tree_limbs << %w(1 2 3 4 6)
tree_limbs << %w(1 2 3 8 9 10 11)
tree_limbs << %w(1 2 3 8 9 10 12)
在 ruby 中构建这样一个哈希树的有效方法是什么:
tree_hash = {1 =>
{2 =>
{3 =>
{4 =>
{5 =>
{7 => nil}
},
{6 => nil}
},
{8 =>
{9 =>
{10 =>
{11 => nil},
{12 => nil}
}
}
}
}
}
}