mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
Merge pull request #4980 from jlp765/tostring
Add nill value handling for seq/sets to system.CollectionToString()
This commit is contained in:
@@ -2334,7 +2334,8 @@ proc collectionToString[T: set | seq](x: T, b, e: string): string =
|
||||
var firstElement = true
|
||||
for value in items(x):
|
||||
if not firstElement: result.add(", ")
|
||||
result.add($value)
|
||||
if value.isNil: result.add "nil"
|
||||
else: result.add($value)
|
||||
firstElement = false
|
||||
result.add(e)
|
||||
|
||||
|
||||
2
tests/stdlib/tnilecho.nim
Normal file
2
tests/stdlib/tnilecho.nim
Normal file
@@ -0,0 +1,2 @@
|
||||
var x = @["1", nil, "3"]
|
||||
doAssert $x == "@[1, nil, 3]"
|
||||
Reference in New Issue
Block a user