Simpler way to add a common filter to reduce the s...
# android
z
Simpler way to add a common filter to reduce the same variable call
Copy code
players.filter {
    it.pStatus != "E" && it.pStatus != "I" && it.pStatus != "S" && it.pStatus != "D" && it.pStatus != "R" && it.pStatus != "NIS"
}
l
Is this better?
Copy code
val invalidStatuses = setOf("E", "I", "S", "D", "NIS")
players.filter { it.pStatus !in invalidStatuses }
6
💯 2
z
Yes this is much cleaner Thank you Luc