feat: abstract List's toString into generic join method on Sequence

Add `join` and `join(sep)` methods to the `Sequence` class, allowing any sequence to produce a concatenated string of its elements with an optional separator. Refactor `List.toString` to delegate to `join(", ")` with bracket wrapping, removing the manual iteration logic from List. Include new test files for List, Range, and String join behavior, plus runtime error tests for non-string separators.
This commit is contained in:
Gavin Schulz
2015-01-24 04:45:23 +00:00
parent c65b03ac32
commit 9e20b3935a
9 changed files with 76 additions and 18 deletions
+4
View File
@@ -0,0 +1,4 @@
var a = 1..3
IO.print(a.join) // expect: 123
IO.print(a.join(", ")) // expect: 1, 2, 3