0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

rubyのmethod_missingについて

0
Posted at

rubyでは存在しないメソッドを呼び出すとmethod_missingが呼び出される
https://docs.ruby-lang.org/ja/latest/method/BasicObject/i/method_missing.html

これを利用し、rubyでProxyクラスを実装する場合、method_missingを利用すると、簡単に実装することができる
https://morizyun.github.io/ruby/design-pattern-proxy.html

class Sample
  def method_missing(method_name, *args)
    puts method_name
    p args
  end
end

Sample.new.unknown_method(1,2,3)
# > unknown_method
# > [1, 2, 3]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?