Skip to content

Instantly share code, notes, and snippets.

@284km
Last active November 18, 2017 13:22
Show Gist options
  • Save 284km/ad4ce5a2312b95a8f0a8b30f8ecdb401 to your computer and use it in GitHub Desktop.
Save 284km/ad4ce5a2312b95a8f0a8b30f8ecdb401 to your computer and use it in GitHub Desktop.
# 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