How to check if an array of strings contains a value in Kotlin

The equivalent you are looking for is the contains operator.

array.contains("value") 

Kotlin offer an alternative infix notation for this operator:

"value" in array

It’s the same function called behind the scene, but since infix notation isn’t found in Java we could say that in is the most idiomatic way.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)