Contents

subscript(_:as:default:)

Reads and writes the value associated with the given key converted to the specified type, falling back to the given default value.

Declaration

subscript<T>(key: String, as type: T.Type = T.self, default defaultValue: @autoclosure () -> T) -> T where T : BinaryFloatingPoint { get }

Parameters

  • key:

    The key the look up in the dictionary.

  • type:

    The expected type for the returned value.

  • defaultValue:

    The value to use if no value for key exists or if conversion to type fails.

Return Value

The value associated with key in the dictionary; otherwise, nil.

See Also

Accessing keys and values