Skip to content

Instantly share code, notes, and snippets.

@richardiux
Created December 10, 2010 22:14
Show Gist options
  • Save richardiux/736911 to your computer and use it in GitHub Desktop.
Save richardiux/736911 to your computer and use it in GitHub Desktop.

Revisions

  1. richardiux renamed this gist Dec 10, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. richardiux created this gist Dec 10, 2010.
    13 changes: 13 additions & 0 deletions Class that behaves like array
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    class A
    def method_missing(method_sym, *arguments, &block)
    if method_sym == :[] && arguments.first.is_a?(Integer)
    # do something here with value (search something or create)
    arguments.first
    else
    super
    end
    end
    end

    a = A.new
    a[2]