in Operator in Kotlin Hindi
The
in operator is used to check whether an object belongs to a collection.| Operator | Expression | Translates to |
|---|---|---|
| in | a in b | b.contains(a) |
| !in | a !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