contains
Checks if the specified element is contained in this collection.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val collection: Collection<Int> = listOf(1, 2, 3)
println("1 in collection is ${1 in collection}") // true
println("4 in collection is ${4 in collection}") // false
// Ref does not override equals, so instances compared by reference
class Ref<T>(val value: T)
val r0 = Ref(42)
val refCollection: Collection<Ref<Int>> = listOf(r0)
println("r0 in refCollection is ${r0 in refCollection}") // true
// Ref(42) is a new instance
println("Ref(42) in refCollection is ${Ref(42) in refCollection}") // false
//sampleEnd
}