OptionalKeyPath

public struct OptionalKeyPath

OptionalKeyPath represents the path to a specific node in a tree of nested dictionaries.

Can be created from string and array literals and can be joined by the =>? operator.

 let a: OptionalKeyPath = "a"
 let b: OptionalKeyPath = ["a", "b"]
 let c: OptionalKeyPath = "a" =>? "b" =>? "c"

Unlike KeyPath, OptionalKeyPath allows each key to be either required or optional. isRequired is false by default.

When a KeyPath is converted to a OptionalKeyPath, isRequired is set to true.

 let c: OptionalKeyPath = "a" =>? "b" => "c"
                                         ^^
                             isRequired=true

In the above example "c" is inferred as KeyPath, then converted to OptionalKeyPath with isRequired = true