kotlin
I have 2 mutableLists for new countries and current countries
I want to remove the countries from listOfCurrentCountry only if they exist in listOfNewCountry
For this I am using the removeIf and firstOrNull to check if the listOfCurrentCountry is in the listOfNewCountry.
val listOfNewCountry = topsProductFilter.items
val listOfCurrentCountry = selectedCountryItemsStateFlow.value
listOfCurrentCountry.removeIf { currentCountry ->
val result = listOfNewCountry.firstOrNull { country ->
currentCountry.value == country.value
}
result == null
}
Just wondering if there is a more kotlin concise way of doing this.