Apple’s added some great features in Swift 4.2 release, so in this post, we’re going to use some of them to achieve a neat key-syntax feature for the Dictionary, but before reading further you by far have to know about the Dynamic Member Lookup. I recommend that you to get acquainted with this feature by the first link — there’re great examples in a simple form.

TL;DR “At the core of this feature is a new attribute called @dynamicMemberLookup , which instructs Swift to call a subscript method when accessing properties. This subscript method, subscript(dynamicMember:) , is required: you’ll get passed the string name of the property that was requested, and can return any value you like.”