Structures
The following structures are available globally.
-
KeyPathrepresents 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.
See morelet a: KeyPath = "a" let b: KeyPath = ["a", "b"] let c: KeyPath = "a" => "b" => "c"Declaration
Swift
public struct KeyPath
-
A key in a keyPath that may or may not be required.
Trying to access a invalid key in a dictionary with an
See moreOptionalKeywill usually result in a nil return value instead of a thrown error. UnlessisRequiredistrue, in which it behaves as anormal
Stringinside anormal
KeyPath.Declaration
Swift
public struct OptionalKey -
OptionalKeyPathrepresents 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,OptionalKeyPathallows each key to be either required or optional.isRequiredisfalseby default.When a
KeyPathis converted to a OptionalKeyPath,isRequiredis set totrue.let c: OptionalKeyPath = "a" =>? "b" => "c" ^^ isRequired=trueIn the above example
See more"c"is inferred asKeyPath, then converted toOptionalKeyPathwithisRequired = trueDeclaration
Swift
public struct OptionalKeyPath
Structures Reference