getOrDefault method

V getOrDefault(
  1. K key,
  2. V defaultValue
)

Returns the value for key, or defaultValue if the key is absent.

{'a': 1}.getOrDefault('b', 0) // 0

Implementation

V getOrDefault(K key, V defaultValue) => this[key] ?? defaultValue;