Skip to content

Instantly share code, notes, and snippets.

@ptzn
Created December 25, 2009 18:33
Show Gist options
  • Save ptzn/263706 to your computer and use it in GitHub Desktop.
Save ptzn/263706 to your computer and use it in GitHub Desktop.
object cloning #1
>> str = "This is a test string"
=> "This is a test string"
>> str1 = str.dup
=> "This is a test string"
>> str1 = "Another string"
=> "Another string"
>> str
=> "This is a test string"
>> arr = [1, 2, 3]
=> [1, 2, 3]
>> arr1 = arr.dup
=> [1, 2, 3]
>> arr1 => [1, 2, 3, 4]
>> arr
=> [1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment