diff options
author | apense <apense@users.noreply.github.com> | 2015-07-06 15:47:23 -0400 |
---|---|---|
committer | apense <apense@users.noreply.github.com> | 2015-07-06 15:47:23 -0400 |
commit | 30737ea34b95b10cd9add766a4397b7e3934efb4 (patch) | |
tree | 5ceea9fe971f89c34f1bcb680996e056795a9077 /lib | |
parent | a7f769c6bddc202587f228b586404fbba09a0e7d (diff) | |
download | Nim-30737ea34b95b10cd9add766a4397b7e3934efb4.tar.gz |
Added safeAdd documentation
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 2677e4990..4ea880b4b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3286,14 +3286,19 @@ when declared(initDebugger): when hasAlloc: # XXX: make these the default (or implement the NilObject optimization) proc safeAdd*[T](x: var seq[T], y: T) {.noSideEffect.} = + ## Add `y` to `x` unless `x` is not yet initialized; in that case, `x` + ## becomes `@[y]` if x == nil: x = @[y] else: x.add(y) proc safeAdd*(x: var string, y: char) = + ## Add `y` to `x`. If `x` is `nil` it is initialized to `""` if x == nil: x = "" x.add(y) proc safeAdd*(x: var string, y: string) = + ## Add `y` to `x` unless `x` is not yet initalized; in that case, `x` + ## becomes `y` if x == nil: x = y else: x.add(y) |