Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubyrefinements usingSingle-choice MCQ

A refinement adds Array#second. A class Parent activates it with `using R` and defines `get`. A subclass Child (in the same file, after Parent's full definition) defines `get2` that also calls `arr.second`. What happens?

module R refine Array do def second; self[1]; end end end class Parent using R def get(arr); arr.second; end end class Child < Parent def get2(arr); arr.second; end end Parent.new.get([10, 20]) # ? Child.new.get2([10, 20]) # ?