Last active
June 13, 2020 12:52
-
-
Save aainaj/51e1c6bd69cd8c113e35f4a55795394f to your computer and use it in GitHub Desktop.
Consumption of ReferenceKeyPathEditable by Class
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
class Merchant: ReferenceKeyPathEditable { | |
typealias Root = Merchant | |
private(set) var name: String | |
private(set) var occupation: String | |
init(name: String, occupation: String) { | |
self.name = name | |
self.occupation = occupation | |
} | |
} | |
let merchant = Merchant(name: "Ryan", occupation: "Grocery Business") | |
print("** Initial: \(merchant.occupation) **") | |
try? merchant.update(type: merchant, path: \Merchant.occupation, to: "Furniture Business") | |
print("** Updated: \(merchant.occupation) **") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment