summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authordata-man <datamanrb@gmail.com>2018-06-01 21:28:23 +0300
committerdata-man <datamanrb@gmail.com>2018-06-01 21:28:23 +0300
commitb4626a220b2de0fee7360672915332c402bf9dc7 (patch)
treef4e22f5cd2818f258b0a57d930f4d9c7d50d7a5a /lib
parentcb87bba82fa81240ea449e13a99280ce134096db (diff)
downloadNim-b4626a220b2de0fee7360672915332c402bf9dc7.tar.gz
Added $ for openarrays. Fixes #7940.
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim8
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)