Created
April 7, 2011 07:02
-
-
Save tallakt/907190 to your computer and use it in GitHub Desktop.
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
#old style | |
a={} | |
a[:test] = {} | |
a[:test][:second_test] = 'Hello hash!' | |
# new style | |
# emulates working with directories | |
b = {} | |
b/:test = {} | |
b/:test/:second_test = 'Hello hash!' | |
# other examples | |
b = [4 => 'goodbye', 5 => 'hello'} | |
puts b/5 | |
c = [1, 2, 3, 4, 5] | |
puts c/3 | |
# extension to Hash class | |
class Hash | |
def /(index) | |
self[index] | |
end | |
# this will not work unfortunately | |
def /=(index, value) | |
self[index] = value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @kaiwren, maybe https://github.com/c42/wrest could use this for composing large URIs from a base URI.