KT-20357: Add sample for Collections distinct and distinctBy methods

This commit is contained in:
Tillmann Berg
2019-11-26 14:44:43 +01:00
committed by ilya-g
parent f0e67f8397
commit cf86dc9a89
5 changed files with 54 additions and 0 deletions
@@ -448,6 +448,13 @@ class Collections {
assertPrints(withLengthOfNames, "{Grace Hopper=11, Jacob Bernoulli=14}")
}
@Sample
fun distinctAndDistinctBy() {
val list = listOf('a', 'A', 'b', 'B', 'A', 'a')
assertPrints(list.distinct(), "[a, A, b, B]")
assertPrints(list.distinctBy { it.toUpperCase() }, "[a, b]")
}
@Sample
fun groupBy() {
val words = listOf("a", "abc", "ab", "def", "abcd")