Skip to content

Instantly share code, notes, and snippets.

@kylebshr
Last active January 31, 2019 19:06
Show Gist options
  • Save kylebshr/a34c3d0a2ca42282d4bec536ee00d6b1 to your computer and use it in GitHub Desktop.
Save kylebshr/a34c3d0a2ca42282d4bec536ee00d6b1 to your computer and use it in GitHub Desktop.
(Weird?) behavior with Codable and properties
// Decoding a `Bar` gives you the same UUID that it was encoded with
struct Bar: Codable {
let id: UUID
init() {
self.id = UUID()
}
}
// Decoding a `Foo` gives you a new UUID
struct Foo: Codable {
let id = UUID()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment