added a partition helper method to partition a collection into a collection of matching items and not matching items

This commit is contained in:
James Strachan
2012-09-12 15:55:34 +01:00
parent 6c4102bf23
commit ba01576c41
12 changed files with 206 additions and 0 deletions
+8
View File
@@ -156,6 +156,14 @@ class CollectionTest {
}
}
test fun partition() {
val data = arrayList("foo", "bar", "something", "xyz")
val pair = data.partition{it.size == 3}
assertEquals(arrayList("foo", "bar", "xyz"), pair.first, "pair.first")
assertEquals(arrayList("something"), pair.second, "pair.second")
}
test fun reduce() {
expect("1234") {
val list = arrayList("1", "2", "3", "4")