The below code gives compile time error - Unreachable statement
while(true)
return;
return; // Unreachable statement
But, the following code does not give any error:
if(true)
return;
return; // Reachable, No Error
I am unable to understand why the compiler recognizes that in case of while, the 2nd return statement will never be reached, but it does not recognize the same in case of if?