lib/standard: the single parameter of `Collection::join` is optional
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 11 Jul 2015 17:25:22 +0000 (13:25 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 17 Jul 2015 14:10:12 +0000 (10:10 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/standard/text/abstract_text.nit

index 93d613f..f8d5c73 100644 (file)
@@ -1598,11 +1598,14 @@ redef class Collection[E]
                return s.to_s
        end
 
-       # Concatenate and separate each elements with `sep`.
+       # Concatenate and separate each elements with `separator`.
        #
-       #     assert [1, 2, 3].join(":")         == "1:2:3"
-       #     assert [1..3].join(":")            == "1:2:3"
-       fun join(sep: Text): String
+       # Only concatenate if `separator == null`.
+       #
+       #     assert [1, 2, 3].join(":")    == "1:2:3"
+       #     assert [1..3].join(":")       == "1:2:3"
+       #     assert [1..3].join            == "123"
+       fun join(separator: nullable Text): String
        do
                if is_empty then return ""
 
@@ -1616,7 +1619,7 @@ redef class Collection[E]
                # Concat other items
                i.next
                while i.is_ok do
-                       s.append(sep)
+                       if separator != null then s.append(separator)
                        e = i.item
                        if e != null then s.append(e.to_s)
                        i.next