Subscript

subscript(_:default:)

Accesses the element with the given key, or the specified default value, if the dictionary doesn’t contain the given key.

Declaration

subscript(key: Dictionary.Key, default defaultValue: @autoclosure () -> Dictionary.Value) -> Dictionary.Value { get set }

See Also

Accessing Keys and Values

subscript(Dictionary.Key)

Accesses the value associated with the given key for reading and writing.

func index(forKey: Dictionary.Key)

Returns the index for the given key.

subscript(Dictionary<Key, Value>.Index)

Accesses the key-value pair at the specified position.

var first: (key: Key, value: Value)?

The first element of the collection.

var keys: Dictionary<Key, Value>.Keys

A collection containing just the keys of the dictionary.

var values: Dictionary<Key, Value>.Values

A collection containing just the values of the dictionary.