Skip to content

Instantly share code, notes, and snippets.

@roop
Created June 26, 2014 07:01
Show Gist options
  • Save roop/5c7af3a89cb6c2390e12 to your computer and use it in GitHub Desktop.
Save roop/5c7af3a89cb6c2390e12 to your computer and use it in GitHub Desktop.
class MyClass {
var value: Int
init(value v: Int) { value = v }
}
var instanceOfMyClass = MyClass(value: 42)
var assignedInstance2 = instanceOfMyClass
assignedInstance2.value = 2 // Change the copied instance
instanceOfMyClass.value // 2: Original is also changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment