Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Created January 11, 2018 06:41
Show Gist options
  • Save agoiabel/2ebd80066604c8dcbadcaa736c018a80 to your computer and use it in GitHub Desktop.
Save agoiabel/2ebd80066604c8dcbadcaa736c018a80 to your computer and use it in GitHub Desktop.
class Dog {
let name: String
var age: Int
var breed: String
init(name: String, age: Int, breed: String) {
self.name = name
self.age = age
self.breed = breed
}
}
var dog1 = Dog(name: "Jerry", age: 2, breed: "Poodle")
var dog2 = dog1
dog2.name = "JaneDony" //we assign a new name to dog2 and this will automatically change dog1 name too since they are reference
dog1.name //will be equal to :::"JaneDony"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment