Skip to content

Instantly share code, notes, and snippets.

@bquorning
Created February 19, 2018 20:53
Show Gist options
  • Save bquorning/a8973da215ac810c21e3ac79bdce9726 to your computer and use it in GitHub Desktop.
Save bquorning/a8973da215ac810c21e3ac79bdce9726 to your computer and use it in GitHub Desktop.
Did Ruby 2.5 introduce a new bug, or fix an old bug? The implicit `flatten` -> `to_ary` -> `respond_to_missing` call has changed.
class A
def respond_to?(method, include_all = false)
::Kernel.puts "respond_to?(#{method.inspect}, #{include_all.inspect})"
end
end
class B
def respond_to_missing?(method, include_all = false)
::Kernel.puts "respond_to_missing?(#{method.inspect}, #{include_all.inspect})"
end
end
puts RUBY_VERSION
[A.new, B.new].flatten
# Output:
#
# 2.4.2
# respond_to?(:to_ary, true)
# respond_to_missing?(:to_ary, false)
#
# 2.5.0
# respond_to?(:to_ary, true)
# respond_to_missing?(:to_ary, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment