Home   Help Search Login Register  

Author Topic: defined || undefined  (Read 904 times)

0 Members and 1 Guest are viewing this topic.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
defined || undefined
« on: 06 Jul 2007, 12:33:16 »
Take care of that, as these sentences will return false always:

_a = true
?_a || _b: hint "at least one of them is true"

You will never get the hint as _b is undefined.

_a = true
_b = false
?_a || _b: hint "at least one of them is true"

This time you will get the hint.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: defined || undefined
« Reply #1 on: 06 Jul 2007, 15:24:09 »
That is why we need short circuit and and or in ArmA, a suggestion I made on the BI forums...
Kegety did post a workaround for xor:
Code: [Select]
if({_x}count[A, B] == 1) then {
   // true
} else {
   // false
};

Would the following work for your case i.e. _a and _b possibly undefined?:
Code: [Select]
if  ({_x} count [_a,_b] > 0) ...
urp!