Skip to content

Instantly share code, notes, and snippets.

@amolbrid
Created November 28, 2010 02:34
Show Gist options
  • Save amolbrid/718518 to your computer and use it in GitHub Desktop.
Save amolbrid/718518 to your computer and use it in GitHub Desktop.
dup and clone difference
str = "Hello"
str.freeze
str_clone = str.clone
puts "str_clone is still frozen" if str_clone.frozen?
str_dup = str.dup
puts "str_dup is not frozen" unless str_dup.frozen?
# output:
# str_clone is still frozen
# str_dup is not frozen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment