Last active
April 23, 2020 18:36
-
-
Save akshitzaveri/a36eba41e31c3f925051517d815a4b7c 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
init?(from document: [String: Any]) { | |
guard let idString = document["id"] as? String, | |
let id = Int(idString), | |
let name = document["name"] as? String, | |
let priceString = document["pricePerUnit"] as? String, | |
let price = Double(priceString) else { return nil } | |
self.init(id: id, name: name, pricePerUnit: price) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment