Skip to content

Instantly share code, notes, and snippets.

@aainaj
Last active June 13, 2020 12:52
Show Gist options
  • Save aainaj/51e1c6bd69cd8c113e35f4a55795394f to your computer and use it in GitHub Desktop.
Save aainaj/51e1c6bd69cd8c113e35f4a55795394f to your computer and use it in GitHub Desktop.
Consumption of ReferenceKeyPathEditable by Class
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