Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRubyobject memory RVALUE embedded stringsSingle-choice MCQ

What does the snippet print, and what does it reveal about embedded vs heap string storage?

require 'objspace' short = "hi" long = "x" * 1000 puts ObjectSpace.memsize_of(short) - ObjectSpace.memsize_of("") puts ObjectSpace.memsize_of(long) - ObjectSpace.memsize_of("")