LoginSignup
1
1

More than 5 years have passed since last update.

インスタンス変数にメソッドを回す Forwardable メモ

Posted at

項目21 「コレクションクラスからの継承よりも委譲を使うようにしよう」

http://magazine.rubyist.net/?0012-BundledLibraries
インスタンス変数にメソッドを回すことができる。

require 'forwardable'

class RaisingHash
  extend Forwardable

  def_delegators(:@hash, :[], :[]=, :has_key?)
  ...
1
1
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
1
1