Add TableRef version of mgetOrPut.
This commit is contained in:
parent
7c1c9a6a9d
commit
614a1f9d5a
1 changed files with 5 additions and 0 deletions
|
|
@ -397,6 +397,11 @@ proc mget*[A, B](t: TableRef[A, B], key: A): var B =
|
||||||
## If `key` is not in `t`, the ``EInvalidKey`` exception is raised.
|
## If `key` is not in `t`, the ``EInvalidKey`` exception is raised.
|
||||||
t[].mget(key)
|
t[].mget(key)
|
||||||
|
|
||||||
|
proc mgetOrPut*[A, B](t: TableRef[A, B], key: A, value: B): var B =
|
||||||
|
## retrieves value at ``t[key]`` or puts ``value`` if not present, either way
|
||||||
|
## returning a value which can be modified.
|
||||||
|
t[].mgetOrPut(key, value)
|
||||||
|
|
||||||
proc hasKey*[A, B](t: TableRef[A, B], key: A): bool =
|
proc hasKey*[A, B](t: TableRef[A, B], key: A): bool =
|
||||||
## returns true iff `key` is in the table `t`.
|
## returns true iff `key` is in the table `t`.
|
||||||
result = t[].hasKey(key)
|
result = t[].hasKey(key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue