diff options
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 08de426c4..ad0ef6287 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1597,6 +1597,18 @@ proc `$`*[T: tuple|object](x: T): string = result.add($value) result.add(")") +proc `$`*[T: set](x: T): string = + ## generic ``$`` operator for sets 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 > 1: 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 |