Probably i am missing something simple, but i do not understand how to use Ruby's DelegateClass
method, i mean when to use it instead of SimpleDelegator
class. For example, all of the following seem to work mostly identically:
require 'delegate'
a = SimpleDelegator.new([0])
b = DelegateClass(Array).new([0])
c = DelegateClass(String).new([0])
a << 1
b << 2
c << 3
p a # => [0, 1]
p b # => [0, 2]
p c # => [0, 3]
Note that it does not seem to matter which class is passed to DelegateClass
.