From: Yusuke Endoh Date: 2010-04-28T01:19:37+09:00 Subject: [ruby-core:29819] [Bug #2224] lib/delegate: operator delegation Issue #2224 has been updated by Yusuke Endoh. Assigned to set to Yukihiro Matsumoto Target version set to 1.9.2 Hi, > The operators ==, =~, !~ are forwarded by Delegate. I presume the operators != and ~, new in 1.9, have simply been forgotten? Agreed. Yugui, do you permit to fix this? > As for eql? and hash, this is probably intentional. I am still curious as to why, since this can yield surprising results (at least to me): Me too. Matz, is this really intentional? I wrote a patch, but I cannot anticipate the impact. At least, make check and make test-rubyspec seem to pass. diff --git a/lib/delegate.rb b/lib/delegate.rb index f366091..e35d3b2 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -117,7 +117,7 @@ class Delegator < BasicObject kernel = ::Kernel.dup kernel.class_eval do - [:to_s,:inspect,:=~,:!~,:===,:<=>].each do |m| + [:to_s,:inspect,:=~,:!~,:===,:<=>,:eql?,:hash].each do |m| undef_method m end end @@ -168,6 +168,15 @@ class Delegator < BasicObject self.__getobj__ == obj end + def !=(obj) + return true if !obj.equal?(self) + self.__getobj__ != obj + end + + def ! + !self.__getobj__ + end + # # This method must be overridden by subclasses and should return the object # method calls are being delegated to. -- Yusuke Endoh ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2224 ---------------------------------------- http://redmine.ruby-lang.org