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
@@ -73,6 +73,10 @@ public class SequenceTest {
}
}
test fun mapAndJoinToString() {
assertEquals("3, 5, 8", fibonacci().withIndex().filter { it.index > 3 }.take(3).joinToString { it.value.toString() })
}
test fun withIndex() {
val data = sequenceOf("foo", "bar")
val indexed = data.withIndex().map { it.value.substring(0..it.index) }.toList()