getOrPut method

V getOrPut(
  1. K key,
  2. V put()
)

Returns the value for key, computing and storing it if absent.

Implementation

V getOrPut(K key, V Function() put) {
  if (!containsKey(key)) {
    this[key] = put();
  }
  return this[key] as V;
}