Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubyfreeze and immutabilitySingle-choice MCQ

With the magic comment `# frozen_string_literal: true` not present, comparing identical frozen string literals with `equal?` gives a different result than non-frozen ones. Why?

a = "hello".freeze b = "hello".freeze p a.equal?(b) # ? c = "world" d = "world" p c.equal?(d) # ?