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

With the frozen-string-literal magic comment enabled, two identical string literals in different methods often end up as the exact same object (same object_id). What MRI mechanism makes this deduplication happen?

# frozen_string_literal: true def a; "hello"; end def b; "hello"; end # a.equal?(b) often true