Can someone please explain this to me?
They are pretty similar but each has a few special features.
switch
if else
break
goto
It is not really clear how to format switch correctly. Semantically, the cases are jump targets (like labels for goto) which should be flush left. Things get worse when you have curly braces:
case XXX: { } break;
Or should the braces go into lines of their own? Should the closing brace go behind the break? How unreadable would that be? etc.
if-else
if
else
2.1m questions
2.1m answers
60 comments
57.0k users