Created
January 11, 2018 06:41
-
-
Save agoiabel/2ebd80066604c8dcbadcaa736c018a80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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