Add an optional parameter to joinToString() and joinTo() functions: lambda function which maps the element to string.

#KT-5468 Fixed
This commit is contained in:
Ilya Gorbunov
2015-04-21 20:54:30 +03:00
parent c8a76f6344
commit d531d7130f
5 changed files with 67 additions and 53 deletions
@@ -267,4 +267,10 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(6, reduced.length())
assertTrue(reduced == "foobar" || reduced == "barfoo")
}
Test
fun mapAndJoinToString() {
val result = data.joinToString(separator = "-") { it.toUpperCase() }
assertEquals("FOO-BAR", result)
}
}