Ticket Created
over 3 years ago

CIQQA-1312

int and logical &&

4.1.3 win/eclipse

var x = 2, y= 4;
if(x)         {LOG.println(true);} else {LOG.println(false);}
if(y)         {LOG.println(true);} else {LOG.println(false);}
if(x && y)    {LOG.println(true);} else {LOG.println(false);}

prints

true
true
false <--- bug

Parents
  • Well, IMO it should be a compile-time error (when using && or || on numbers), which avoids any issues with existing code breaking at run-time.

    The worst part is that && of two numbers is logical AND but || is not (it works like javascript and returns the first operand which is not falsey).

Comment
  • Well, IMO it should be a compile-time error (when using && or || on numbers), which avoids any issues with existing code breaking at run-time.

    The worst part is that && of two numbers is logical AND but || is not (it works like javascript and returns the first operand which is not falsey).

Children