Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubymethod_missing and respond_to_missingSingle-choice MCQ

What is the value of `respond_to?(:anything)` for these two objects, where both define method_missing but only the second overrides respond_to_missing?

class Ghost def method_missing(n, *a) = "ghost" end class Ghost2 def method_missing(n, *a) = "ghost" def respond_to_missing?(n, priv = false) = true end [Ghost.new.respond_to?(:anything), Ghost2.new.respond_to?(:anything)]