extend Forwardable : Forwardable « Collections « Ruby






extend Forwardable


require 'forwardable'

class AppendOnlyArray
  extend Forwardable
  def initialize
    @array = []
  end

  def_delegator :@array, :<<
end

a = AppendOnlyArray.new
a << 4
a << 5


 








Related examples in the same category

1.extending Forwardable delegates to hash
2.Easing the Delegation Blues