Created
February 13, 2011 23:29
-
-
Save l1x/825300 to your computer and use it in GitHub Desktop.
Nested Hashes with Symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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