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

With this Dyn class, what do d.respond_to?(:calc_x) and d.respond_to?(:calc_x, true) return?

class Dyn def respond_to_missing?(name, include_private = false) name.to_s.start_with?("calc_") end def method_missing(name, *) name.to_s.start_with?("calc_") ? 42 : super end end d = Dyn.new