Skip to content

Instantly share code, notes, and snippets.

@borowskiio
Last active February 17, 2016 08:26
Show Gist options
  • Save borowskiio/44c3eb71f673941eca99 to your computer and use it in GitHub Desktop.
Save borowskiio/44c3eb71f673941eca99 to your computer and use it in GitHub Desktop.
Produce PHP-style multidimensional array, e.g arr[1][2][3] = 'foobar'
# 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
@agnel
Copy link

agnel commented Feb 16, 2016

Can you put this on http://www.rubeque.com/ as one of the problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment