HashMap.setDefault

Get or create a value from/in the map.

Given a key, and a lazy evaluated default value, attempt to retrieve a value from the map. If a value for the given key is not set, set the provided default value in the map and return that.

The value will be returned by reference.

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

Parameters

key
Type: K

The key in the map.

Return Value

Type: V

A reference to the value in the map.

Meta