Last active
November 18, 2017 13:22
-
-
Save 284km/ad4ce5a2312b95a8f0a8b30f8ecdb401 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# frozen_string_literal: true | |
a = '' | |
b = String.new | |
c = String.new('') | |
d = String.new('hello_') | |
e = a.dup | |
# a << "hello_a" | |
b << "hello_b" | |
c << "hello_c" | |
d << "hello_d" | |
e << "hello_e" | |
puts a | |
puts b | |
puts c | |
puts d | |
puts e | |
puts "a.frozen?: #{a.frozen?}" | |
puts "b.frozen?: #{b.frozen?}" | |
puts "c.frozen?: #{c.frozen?}" | |
puts "d.frozen?: #{d.frozen?}" | |
puts "e.frozen?: #{e.frozen?}" | |
__END__ | |
$ ruby frozen.rb | |
hello_b | |
hello_c | |
hello_hello_d | |
hello_e | |
a.frozen?: true | |
b.frozen?: false | |
c.frozen?: false | |
d.frozen?: false | |
e.frozen?: false | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment