Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubydup vs cloneSingle-choice MCQ

When you call dup on an instance of a class that defines both initialize and initialize_copy, which of those is invoked on the new copy?

class Widget def initialize; puts "initialize"; end def initialize_copy(o); super; puts "initialize_copy"; end end w = Widget.new # prints initialize w.dup # prints ?