HashMap.setDefault

Get or create a value from/in a hashmap.

Given a key attempt to retrieve a value from the hashmap. If a value for the given key is not set, set the value in the associative array to the default value for the value's type.

The value will be returned by reference.

  1. V setDefault(K key, lazy V2 value)
  2. V setDefault(K key)
    struct HashMap(K, V)
    ref
    V
    setDefault
    (
    K key
    )
    if (
    isAssignmentCopyable!(Unqual!K) &&
    isAssignmentCopyable!(Unqual!V)
    )

Parameters

key
Type: K

The key in the map.

Return Value

Type: V

A reference to the value in the map.

Meta