Last active
May 3, 2019 17:25
-
-
Save SURYAKANTSHARMA/981077616d8c140f8ad19e0ac2a857d9 to your computer and use it in GitHub Desktop.
Avoid Singleton
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
func saveUserBalance(user: User, buyingAmount: Double, defaults: UserDefaults = UserDefaults.standard) { | |
let remainingBalance = user.balance - buyingAmount | |
// save user balance for persistance | |
defaults.set(remainingBalance, forKey: "userBalance") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment