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

In CRuby 3.x, both expressions are evaluated repeatedly at runtime. Which statement correctly explains why one form deduplicates equal-content strings into a single shared frozen object and the other does not?

a = "pre#{ENV['X']}".freeze b = "pre#{ENV['X']}".freeze c = -"pre#{ENV['X']}" d = -"pre#{ENV['X']}" # Assume ENV['X'] is unset, so all four have equal content.