Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]
Add Comment
Please, Sign In to add comment