News for hackers. Stuff that matters.
Re:"DCI" in Ruby is completely broken by davnola on Wednesday January 02, 2013 @04:22PM (#4999394)
Because in general, delegation tends to lead to object schizophrenia. Specifically, SimpleDelegator will leak the original delegatee object when a delegated method returns `self`.

     s = "foo"
     
     d = SimpleDelegator.new s

     s2 = d << "bar"

     s2.object_id == s # true
I think SimpleDelegator is really neat but totally dangerous. Doesn't this ring alarm bells with you?

  # delegate.rb L117
  #
  # Returns true if two objects are considered of equal value.
  #
  def ==(obj)
    return true if obj.equal?(self)
    self.__getobj__ == obj
  end

There are no comments on this comment yet.