Skip to content

Instantly share code, notes, and snippets.

@akshitzaveri
Last active February 20, 2021 16:29
Show Gist options
  • Save akshitzaveri/441e82ac2b63e55d1aa90c0fbfc35bf1 to your computer and use it in GitHub Desktop.
Save akshitzaveri/441e82ac2b63e55d1aa90c0fbfc35bf1 to your computer and use it in GitHub Desktop.
class Match {
var score: Int
init(score: Int) {
self.score = score
}
}
func finish(_ match: Match) {
match.score = 100 // Updating the score here changes the score on the original copy
}
let match = Match(score: 10)
print(match.score) // prints 10
finish(match) // passing match variable to the function
print(match.score) // prints 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment