Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you put an "extra" (unintended) semicolon on the last expression, the function will return Void/Unit: if this doesn't agree with the given type of the function, then there will be a compiler error. If you forget a semicolon, then the type of the function will become the type of the last expression, which will again make the compile complain.

Are there other issues that you had in mind?



The C++ will complain as well, the issue is ";" is 6 times less characters than "return" and so, easier to overlook.


I think I'd rather have that problem than this problem:

    if (cond); //oops, a semicolon
        alwaysHappens();
, thank you very much.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: