Intermediate
Ruby
Q57 / 100
What does "Object#dup" do compared to "Object#clone"?
Correct! Well done.
Incorrect.
The correct answer is B) Both create a shallow copy of an object, but clone also copies the frozen state and singleton methods, while dup does not
B
Correct Answer
Both create a shallow copy of an object, but clone also copies the frozen state and singleton methods, while dup does not
Explanation
dup and clone both produce shallow copies, but clone preserves frozen status and singleton class methods of the original object, whereas dup resets these.
Progress
57/100