any
Returns true if char sequence has at least one character.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
// any is synonymous to !isEmpty()
println("\"str\".any() is ${"str".any()}") // true
println("\"\".any() is ${"".any()}") // false
//sampleEnd
}Returns true if at least one character matches the given predicate.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val string = "Kotlin"
// All characters are letters
println("string.any { it.isLetter() } is ${string.any { it.isLetter() }}") // true
// Some of them are lowercase letters
println("string.any { it.isLowerCase() } is ${string.any { it.isLowerCase() }}") // true
// But there are no digits among them
println("string.any { it.isDigit() } is ${string.any { it.isDigit() }}") // false
// For an empty string `any` always return `false`
println("\"\".any { true } is ${"".any { true }}") // false
println("\"\".any { false } is ${"".any { false }}") // false
//sampleEnd
}