A short look at Ruby.
December 31, 2008
I had some fun playing with:
1 2 3 4 5 6 7 8
hash_default = proc { |h,k| h[k] = Hash.new(&hash_default) } a_hash = Hash.new(&hash_default) a_hash[:foo] # => {} a_hash # => {:foo => {}} a_hash[:foo][:bar] # => {} a_hash[:foo][:bar][:baz] = 'Yay!' a_hash # => {:foo=>{:bar=>{:baz=>"Yay!"}}}
Boof -- interesting. It makes me wonder/understand why the syntax for procs and hashes is so similar.
Yet another nested hash test here: Basic Trie data structure in Ruby http://snippets.dzone.com/posts/show/5616
<brrrr!/>
I had some fun playing with:
hash_default = proc { |h,k| h[k] = Hash.new(&hash_default) } a_hash = Hash.new(&hash_default) a_hash[:foo] # => {} a_hash # => {:foo => {}} a_hash[:foo][:bar] # => {} a_hash[:foo][:bar][:baz] = 'Yay!' a_hash # => {:foo=>{:bar=>{:baz=>"Yay!"}}}Boof -- interesting.
January 01, 2009 at 9:46 AMIt makes me wonder/understand why the syntax for procs and hashes is so similar.
Yet another nested hash test here:
January 01, 2009 at 4:18 PMBasic Trie data structure in Ruby
http://snippets.dzone.com/posts/show/5616