KT-20357: Add sample for Collections distinct and distinctBy methods
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user