21
I was working on a project and unintentionally bumped into the semicolon that ended up being inserted well after a if
. I was intrigued because Visual Studio did not point out as an error, and when trying to compile the project I was successful.
The code went like this:
if(alguma_coisa)
{
//Bloco lógico
};
Motivated by curiosity, I could notice that it is also possible to insert a semicolon at the end of loops like while
, for
and foreach
.
I showed it to a friend and he revealed the possibility of inserting the semicolon several times in sequence in the same line as follows:
if(alguma_coisa)
{
//Bloco lógico
}; ; ; ; ; ;
And yet the project is compiled without any problem.
A build error should not be generated?
Why is that allowed?
I can barely see your movements
– Jéf Bueno
for those who are not mine - http://www.dicionarioinformal.com.br/in%C3%B3cua/
– PauloHDSousa