Wednesday 6 December 2017

Kotlin Tutorial in Hindi | in Operators



in Operator in Kotlin Hindi

The in operator is used to check whether an object belongs to a collection.
OperatorExpressionTranslates to
ina in bb.contains(a)
!ina !in b!b.contains(a)

Example: in Operator

fun main(args: Array<String>) {

    val numbers = intArrayOf(1, 4, 42, -3)

    if (4 in numbers) {
        println("numbers array contains 4.")
    }
}
When you run the program, the output will be:
numbers array contains 4.

No comments:

Post a Comment