Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRubyfrozen string dedupSingle-choice MCQ

Why does `-("a" + "b")` return the same deduplicated object on repeated runs, while `("a" + "b").freeze` does not, even though both produce a frozen string of "ab"?

x = -("a" + "b") y = -("a" + "b") p x.equal?(y) # true m = ("a" + "b").freeze n = ("a" + "b").freeze p m.equal?(n) # false