Add TableRef version of mgetOrPut.

This commit is contained in:
Charles Blake
2015-02-16 06:02:31 -05:00
parent 7c1c9a6a9d
commit 614a1f9d5a

View File

@@ -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.
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 =
## returns true iff `key` is in the table `t`.
result = t[].hasKey(key)