Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jul 16th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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