diff options
author | data-man <datamanrb@gmail.com> | 2018-06-01 21:28:23 +0300 |
---|---|---|
committer | data-man <datamanrb@gmail.com> | 2018-06-01 21:28:23 +0300 |
commit | b4626a220b2de0fee7360672915332c402bf9dc7 (patch) | |
tree | f4e22f5cd2818f258b0a57d930f4d9c7d50d7a5a /lib | |
parent | cb87bba82fa81240ea449e13a99280ce134096db (diff) | |
download | Nim-b4626a220b2de0fee7360672915332c402bf9dc7.tar.gz |
Added $ for openarrays. Fixes #7940.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 06c4f103b..13f16903a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3443,6 +3443,14 @@ when not defined(nimNoArrayToString): ## generic ``$`` operator for arrays that is lifted from the components collectionToString(x, "[", ", ", "]") +proc `$`*[T](x: openarray[T]): string = + ## generic ``$`` operator for openarrays that is lifted from the components + ## of `x`. Example: + ## + ## .. code-block:: nim + ## $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]" + collectionToString(x, "[", ", ", "]") + proc quit*(errormsg: string, errorcode = QuitFailure) {.noReturn.} = ## a shorthand for ``echo(errormsg); quit(errorcode)``. echo(errormsg) |