Created
October 3, 2018 21:20
-
-
Save Otbivnoe/26b469e02be213d15433cd6660aad665 to your computer and use it in GitHub Desktop.
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
@dynamicMemberLookup | |
struct Person { | |
subscript(dynamicMember member: String) -> String { | |
let properties = ["name": "Nikita", "age": "24"] | |
return properties[member, default: ""] | |
} | |
} | |
print(Person().name) // Nikita |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment