added a groupBy method (and stumbled on a couple more little compiler bugs which could well be the same as previous issues I've raised this week). Happy holidays everyone :)
This commit is contained in:
@@ -118,6 +118,24 @@ class CollectionTest() : TestSupport() {
|
||||
assertEquals(6, count)
|
||||
}
|
||||
|
||||
fun testGroupBy() {
|
||||
val words = arrayList("a", "ab", "abc", "def", "abcd")
|
||||
/*
|
||||
TODO inference engine should not need this type info?
|
||||
*/
|
||||
val byLength = words.groupBy<String,Int>{it.length}
|
||||
assertEquals(4, byLength.size())
|
||||
|
||||
println("Grouped by length is: $byLength")
|
||||
/*
|
||||
TODO compiler bug...
|
||||
|
||||
val l3 = byLength.getOrElse(3, {ArrayList<String>()})
|
||||
assertEquals(2, l3.size)
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
fun testJoin() {
|
||||
val text = data.join("-", "<", ">")
|
||||
assertEquals("<foo-bar>", text)
|
||||
|
||||
Reference in New Issue
Block a user