Home > Back-end >  What is opposite to 'in' condition in Kotlin - '!` mark equivalent to Java
What is opposite to 'in' condition in Kotlin - '!` mark equivalent to Java

Time:07-07

In Java we do use ! in case we want to say NOT. But what should I use in Kotlin if I follow some range condition.

if( item in 5..10)

So here I want to say if item NOT in 5..10 ?? what is the proper construction?

CodePudding user response:

You can use !in operator:

if (item !in 5..10)

See documentation for a full list of operators:

  • Related