+ 1
Why do we not put a semicolon after repetition(except do-while) and selection structure?
Why do we not put a semicolon after repetition(except do-while) and selection structure?
1 Antwort
+ 5
The {} block does it all. It stops the code after the function is over.
Otherwise, the semicolon of the statement inside helps terminate the code after one iteration.
The block is designed as such to terminate the code only when the function has finished execution.
Thats why its available with only a few functions, inherited mostly from C.
Although, even initializer lists of arrays require the semicolon after the {} block.