Bug #13762
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
Given this code: ```ruby ``` # frozen_string_literal: true class MyProxy < BasicObject def initialize(target) @target = target end undef_method :== def method_missing(method_name, *args, &block) if target_respond_to?(method_name) @target.__send__(method_name, *args, &block) else ::Object .instance_method(method_name) .bind(@target) .call(*args, &block) end end private def target_respond_to?(method_name) ::Object .instance_method(:respond_to?) .bind(@target) .call(method_name, true) end end puts 'a' == MyProxy.new('a') puts MyProxy.new('a') == 'a' puts MyProxy.new('a') == MyProxy.new('a') ``` The output differs depending on the Ruby version: ``` $ chruby 2.3.4 $ ruby test.rb true true true $ chruby 2.4.1 $ ruby test.rb false true false ```