if the condition is compile time constant, then compiler assumes that block executes.
Stuart A. Burkett
Joined: May 30, 2012
In your first example either line 6 or 8 will be executed, so there is no path through the code where i would not be initialised.
If you meant to write just
and wondered why that compiled and the second example didn't, it's because true is a compile time constant. The compiler knows it will always be true, whereas in your second example b is a variable and even though it is set to true on the previous line, the compiler doesn't take that into account and so complains.
If you made b a final variable, it would again become a compile time constant and the compiler would be happy again.