@DeprecatedSinceKotlin("1.4") operator fun FloatArray.contains( element: Float ): BooleanDeprecated: The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.
@DeprecatedSinceKotlin("1.4") operator fun DoubleArray.contains( element: Double ): BooleanDeprecated: The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.
Returns true
if element is found in the array.
Returns true
if element is found in the collection.
Checks if the map contains the given key.
This method allows to use the x in map
syntax for checking whether an object is contained in the map.
import kotlin.test.*
import java.util.*
fun main(args: Array<String>) {
//sampleStart
val map: Map<String, Int> = mapOf("x" to 1)
println("map.contains("x") is ${map.contains("x")}") // true
println(""x" in map is ${"x" in map}") // true
println("map.contains("y") is ${map.contains("y")}") // false
println(""y" in map is ${"y" in map}") // false
//sampleEnd
}
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/contains.html