Created
October 8, 2021 14:35
-
-
Save mbrandonw/0c42c8e16d50b751cb2a6c7db341b02f 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
struct Foo: Identifiable { | |
let id = 42 | |
} | |
let kp1: KeyPath<Foo, Int> = idKeyPath() | |
let kp2: KeyPath<Foo, Int> = idKeyPath() | |
kp1 == kp2 // ✅ true | |
kp1 == \.id // ❌ false | |
kp2 == \.id // ❌ false | |
func idKeyPath<T: Identifiable>() -> KeyPath<T, T.ID> { | |
\.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment