daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Jul 16th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class A
  2.  def method_missing(method_sym, *arguments, &block)
  3.    if method_sym == :[] && arguments.first.is_a?(Integer)
  4.      # do something here with value (search something or create)
  5.      arguments.first
  6.    else
  7.      super
  8.    end
  9.  end
  10. end
  11.  
  12. a = A.new
  13. a[2]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top