DeathVenom
DeathVenom

Reputation: 394

What is the equivalent of !boolean (negative) on Kotlin

I have recently decided to switch from Java to Kotlin for Android Development. I don't know what to Google, so I'm asking here.

If we want to get the opposite of a boolean, we put a ! before it. Eg: I want the inside code to run only if the contains() returns false. How to do that?

Example, we do this in Java:

if (!string_text.contains(" "))

How do I write this in Kotlin?

Upvotes: 0

Views: 1947

Answers (2)

Cesar Galindo
Cesar Galindo

Reputation: 1

Try

if (string_text.isNullOrBlank()) {

info oficial kotlin

Upvotes: -1

al3c
al3c

Reputation: 1452

! is the boolean not operator, same as Java.

Check https://kotlinlang.org/docs/reference/keyword-reference.html#operators-and-special-symbols

Upvotes: 4

Related Questions