Structures

The following structures are available globally.

  • KeyPath 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: KeyPath = "a"
    let b: KeyPath = ["a", "b"]
    let c: KeyPath = "a" => "b" => "c"
    
    See more

    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 OptionalKey will usually result in a nil return value instead of a thrown error. Unless isRequired is true, in which it behaves as a normal String inside a normal KeyPath.

    See more

    Declaration

    Swift

    public struct OptionalKey
  • 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

    See more

    Declaration

    Swift

    public struct OptionalKeyPath