get

Looks up key; if it exists returns corresponding value else evaluates and returns defaultValue.

  1. inout(V) get(inout(V[K]) aa, K key, inout(V) defaultValue)
  2. inout(V) get(inout(V[K])* aa, K key, inout(V) defaultValue)
    inout(V)
    get
    (
    K
    V
    )
    (
    inout(V[K])* aa
    ,
    K key
    ,
    lazy inout(V) defaultValue
    )

Parameters

aa inout(V[K])*

The associative array.

key K

The key.

defaultValue inout(V)

The default value.

Return Value

Type: inout(V)

The value.

Examples

auto aa = ["k1": 1];
assert(aa.get("k1", 0) == 1);
assert(aa.get("k2", 0) == 0);

Meta