https://kotlinlang.org logo
#announcements
Title
# announcements
p

pablofloresarg

11/25/2019, 9:01 PM
Hi guys, I have a problem with this code, I'm returning from repository a Flow<ListHouse>, the list has the house name and I want to filter it by a house name string that I have in my class. In my head filter is returning a new list with just one House so in map I am using first and get values (house values from potter api). But I always get all list house from filter so my first() in map always give me the values of the first house. I don't know why filter is not working with any(), they both are returning boolean from predicate (or at least I think so)
d

Dominaezzz

11/25/2019, 9:09 PM
I think you want
.map { house -> house.first { it.name == this.house }.values }
.
💯 1
filter
will simply return the original list if it contains a house with the correct name. It won't actually return a new list.
p

pablofloresarg

11/26/2019, 11:47 AM
Thanks!! Appreciate, it was really helpful