sorry guys, I was tired when I posted `anyMatch` w...
# functional
d
sorry guys, I was tired when I posted
anyMatch
was a typo, I meant
all { }
and
allMatch { }
@kevinmost @arocnies
Copy code
fun main(args: Array<String>) {

    val x = emptyMap<String,String>()

    println(x.values.all { false })
    println(x.values.all { true })
    println(x.values.all { it.equals("nothing") })

    println(x.values.stream().allMatch( { false }))
    println(x.values.stream().allMatch( { true }))

}
Copy code
true
true
true
true
true

Process finished with exit code 0
@kevinmost I guess I see your point, just wish there was something similar that returned false on
0
elements that I could use. Is there? or do I need to roll my own extension
fun
?
k
There isn't, you'll have to work around it
Copy code
val allMatch = list.takeIf { it.isNotEmpty }?.all { cond } ?: false
Copy code
val allMatch = list.isNotEmpty && list.all { cond }