I don't understand why this function does not work...
# getting-started
n
I don't understand why this function does not work. I expect to get two distinct results and instead I am getting all of the duplicates as well. Any ideas what I am doing wrong?
Copy code
items(state.newsFeedItems) {println(listOf(it.feedTitle).distinct())}
j
listOf(it.feedTitle)
is a list of 1 element. Calling
distinct()
on it has no effect because there cannot be duplicates in this list.
What you want is eliminating the duplicates in the original list instead (the one you pass to
items()
I guess)
n
ah ok, makes sense! Thanks!