We just discovered, a colleague and I, a weird compilation syntax with conditional If syntax :
if (true); { foo(); }
Does anyone here explain this weird syntax to us? thank.
The first part if (true);is just a do-nothing condition that ends with ;. The rest is a call foo()inside a new visibility block. You must find what is foo()always called.
if (true);
;
foo()
if , , ( if). , foo :
if (false); { foo(); }
, .
if (true) { // do nothing } { foo(); }
{} foo(); . , {}, .
{ int i=0; System.out.println(i); } { String i="hello"; System.out.println(i); }
.
,
if (true) {}; foo();
stat if , foo ({}) ...
, , - , ...
, if, .
, (.. ), foo(), . foo() . , , , :
This dead code. The if block is useless.
Equivalent
if(doesn't matter whats here) {} foo();