Skip to content

Instantly share code, notes, and snippets.

@dineshba
Last active May 21, 2018 18:42
Show Gist options
  • Save dineshba/dc2abc37b00d38467d3a7112629a18d0 to your computer and use it in GitHub Desktop.
Save dineshba/dc2abc37b00d38467d3a7112629a18d0 to your computer and use it in GitHub Desktop.
class Dog {
var name: String
var weight: Int
// constructor or initializer
init(name: String, weight: Int) {
self.name = name
self.weight = weight
}
}
var myDog = Dog(name: "Ranger", weight: 10)
var yourDog = myDog // reference copy
yourDog.name = "Puncher"
print(myDog.name) // "Puncher"
print(yourDog.name) // "Puncher"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment