Walee
Walee

Reputation: 13

Objective C syntax?

In Objective C if given that X is an Integer what does is ! X Does it mean a user logical negation operator like Java, or if it has value 0 then X is non zero?

Upvotes: 0

Views: 37

Answers (2)

zaph
zaph

Reputation: 112857

Objective-C is a strict superset of the "C" language so it behaves exactly the same as "C" (which it is). ! is the logical not operator.

int x = 3;
int y = ! x;
int z = ! y;

x: 3
y: 0
z: 1

Upvotes: 0

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726479

Operator ! in Objective-C is the same as in C. It is a logical not operator, which operates on numbers.

  • When the input number is zero, the result is 1
  • When the input is non-zero, the result is zero.

Upvotes: 1

Related Questions