summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2014-02-11 14:16:12 -0600
committerSimon Hafner <hafnersimon@gmail.com>2014-02-11 14:16:12 -0600
commitf6e8da4332eb974a0e2d55872667f21aece57bc8 (patch)
tree0071efa1951249372aa0051f2125091656519226 /lib
parente8c87d070a4fa507208a042e9f02b356eaa567ad (diff)
downloadNim-f6e8da4332eb974a0e2d55872667f21aece57bc8.tar.gz
Added `$` for seq
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 2acb989c5..e7308f5d3 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1672,6 +1672,18 @@ proc `$`*[T: set](x: T): string =
     result.add($value)
   result.add("}")
 
+proc `$`*[T: seq](x: T): string = 
+  ## generic ``$`` operator for seqs that is lifted from the components
+  ## of `x`. Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   $(@[23, 45]) == "@[23, 45]"
+  result = "@["
+  for value in items(x):
+    if result.len > 2: result.add(", ")
+    result.add($value)
+  result.add("]")
+
 when false:
   proc `$`*[T](a: openArray[T]): string = 
     ## generic ``$`` operator for open arrays that is lifted from the elements