-
Notifications
You must be signed in to change notification settings - Fork 23
Collection: Find if all elements are satisfying a particular condition
Devrath edited this page Feb 29, 2024
Β·
1 revision
Code
val countriesList = mutableListOf(
Country(name = "USA", isDemocracy = true),
Country(name = "Australia", isDemocracy = true),
Country(name = "Russia", isDemocracy = false),
Country(name = "England", isDemocracy = true),
Country(name = "North Korea", isDemocracy = false)
)
fun main(args: Array<String>) {
val output = countriesList.all {
it.isDemocracy
}
println("Result-> $output")
}
Output
Result-> false