diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2014-02-11 14:16:12 -0600 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2014-02-11 14:16:12 -0600 |
commit | f6e8da4332eb974a0e2d55872667f21aece57bc8 (patch) | |
tree | 0071efa1951249372aa0051f2125091656519226 /lib | |
parent | e8c87d070a4fa507208a042e9f02b356eaa567ad (diff) | |
download | Nim-f6e8da4332eb974a0e2d55872667f21aece57bc8.tar.gz |
Added `$` for seq
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nim | 12 |
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 |