Skip to content

Instantly share code, notes, and snippets.

@fronx
Created November 27, 2011 13:40
Show Gist options
  • Select an option

  • Save fronx/1397566 to your computer and use it in GitHub Desktop.

Select an option

Save fronx/1397566 to your computer and use it in GitHub Desktop.
recursive_hash = lambda { |h,k| h[k] = Hash.new(&recursive_hash) }
table = Hash.new(&recursive_hash)
table['a']['x'] = 1
table['a']['y'] = 2
table['b']['x'] = 3
table['b']['y'] = 4
# {"a"=>{"x"=>1, "y"=>2}, "b"=>{"x"=>3, "y"=>4}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment