Last active
August 29, 2015 13:56
-
-
Save careo/9283113 to your computer and use it in GitHub Desktop.
freezing strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUBY_DESCRIPTION # => "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]" | |
"one".freeze.object_id # => 70098950078640 | |
one = "one" | |
two = "one" | |
one.object_id # => 70098950065800 | |
two.object_id # => 70098950065780 | |
one.freeze | |
two.freeze | |
one.object_id # => 70098950065800 | |
two.object_id # => 70098950065780 | |
"one".freeze.object_id # => 70098950078640 | |
"one".freeze.object_id # => 70098950078640 | |
hash = {} | |
hash["one"] = "something" | |
hash.keys.first.object_id # => 70098950062960 | |
hash.delete "one" | |
hash["one"] = "something" | |
hash.keys.first.object_id # => 70098950062360 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment