Skip to content

Instantly share code, notes, and snippets.

@avit
Last active June 30, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avit/afb267da0a3ab640fcbb3aa78067fe74 to your computer and use it in GitHub Desktop.
Save avit/afb267da0a3ab640fcbb3aa78067fe74 to your computer and use it in GitHub Desktop.
strings = Hash.new { |h, k| h[k] = k.freeze }
#=> {}
a = strings["asdf"]
#=> "asdf"
a.object_id
#=> 70266940175600
b = strings["asdf"]
b.object_id
#=> 70266940175600
c = "asdf"
c.object_id
#=> 70266937176080
d = strings[c]
d.object_id
#=> 70266940175600
strings.keys.map(&:object_id)
#=> [70266940175600]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment