Last active
February 17, 2016 08:26
-
-
Save borowskiio/44c3eb71f673941eca99 to your computer and use it in GitHub Desktop.
Produce PHP-style multidimensional array, e.g arr[1][2][3] = 'foobar'
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
# Produce PHP-style multidimensional array. | |
# | |
# Example | |
# | |
# arr = Marray.new | |
# | |
# arr[1][2][3] = "foo" | |
# => "foo" | |
# | |
# arr[1][2][3] | |
# => "foo" | |
class Marray < Array | |
def [](i) | |
super.nil? ? self[i] = Marray.new : super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you put this on http://www.rubeque.com/ as one of the problems?