Skip to content

Instantly share code, notes, and snippets.

@l1x
Created February 13, 2011 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l1x/825300 to your computer and use it in GitHub Desktop.
Save l1x/825300 to your computer and use it in GitHub Desktop.
Nested Hashes with Symbols
#/usr/bin/env ruby
silicates = Hash.new {
|h, k| h[k] = Hash.new
}
silicates[:mineral0]["ruby"] = "String + red"
silicates[:mineral1]["ruby"] = "String + blue"
silicates[:mineral2][:ruby] = "Symbol + green"
silicates[:mineral3][:ruby] = "Symbol + black"
silicates.each_pair { |key, value|
value.each { |key, value|
puts value + " : " + key.object_id.to_s
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment