Semicolon at end of 'if' statement

前端 未结 18 1909
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 01:01

Today, after half an hour of searching for a bug, I discovered that it is possible to put a semicolon after an if statement instead of code, like this:

if(a          


        
18条回答
  •  粉色の甜心
    2020-11-22 01:28

    I can't think of an occasion where it is useful. It can be useful for loops like

     while(do something);
    

    or

     for(init; do something; something else);
    

    If you use your code formatting in your IDE regularly these sort of bugs become obvious. Some IDEs highlight this as a probable bug as well.

提交回复
热议问题