Created
June 9, 2018 03:49
-
-
Save vhart/4b13296be2c1d43fe2889f99f1a05cf5 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 MyStruct { | |
let name: String | |
let number: Int | |
var bool: Bool | |
} | |
let instance = MyStruct(name: "Korg", number: 1, bool: true) | |
// Referencing | |
let nameRef: KeyPath<MyStruct, String> = \MyStruct.name | |
// Evaluating | |
let name = instance[keyPath: nameRef] // "Korg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment