Function computeIfAbsent

If the specified key is not already associated with a value in this map, attempts to compute its value using the given mapping function and enters it into this map unless null.

  • Type Parameters

    • K
    • V

    Parameters

    • map: Map<K, V>

      map from which to get the key's value or compute and associate

    • key: K

      key for which to get the value or with which the computed value is to be associated

    • mappingFunction: ((key: K) => V)

      function to compute a value for key

        • (key): V
        • Parameters

          • key: K

          Returns V

    Returns V