Last active
February 20, 2021 16:29
-
-
Save akshitzaveri/441e82ac2b63e55d1aa90c0fbfc35bf1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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