Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
Description
Swift 4.2 introduces the @dynamicMemberLookup attribute. Basically, this is just syntactic sugar, allowing you to use dot notation to look up arbitrary properties on a type.
A natural place for us to use this is on documents. This will allow users to do things like the following:
var doc: Document = ["a": 1, "b": 2] |
print(doc.a) // prints 1 |
print(doc.x) // prints nil |
print(doc.b) // prints 2 |
Implementing this will require adding the attribute to Document, and adding a new subscript(dynamicMember: ) method that behaves identically to our existing subscript getter.