Added $ for seq

This commit is contained in:
Simon Hafner
2014-02-11 14:16:12 -06:00
parent e8c87d070a
commit f6e8da4332
2 changed files with 17 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,5 @@
discard """
output:'''@[23, 45]'''
"""
echo($(@[23, 45]))