Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

TryAdd

func TryAdd(key: K, value: V) -> bool

Declaring type: HashMap<K, V>
Module: System.Collections
Assembly: System.Runtime.dll
Source file: HashMap.rvn

Implements MutableMap<K, V>.TryAdd

Inserts the key and value only when the key is absent; returns false without replacing an existing entry.

Parameters

Name Type Description
key K The key to look up or update.
value V The value on which this operation acts.

Return value

Boolean

True if a new entry was inserted; false if the key already existed.