expecting rightbrace page 2

29 posts

Flag Post

You would be surprised at all the trouble and frustration a novice coder would have trying to find out which } goes with what when problems like this arise. Even with proper indenting which I reccomend, you might have an extra or missing }.

That said you dont have to put comments on ALL of the } but if you have lots of if statements or switch cases or while loops in a function, having }//these comments, can save your sanity

 
Flag Post

Yeah but if you’re having brace confusion it’s a good sign you should split that procedure up into several smaller ones.

 
Flag Post
Originally posted by BobJanova:

Yeah but if you’re having brace confusion it’s a good sign you should split that procedure up into several smaller ones.

I could not agree more.

 
Flag Post

Okay now this just opens up the door as to how big and confusing a function can be even if it is broken down to its possible smallest form.

Everyone goes through brace confusion. I still go through it. Anyone starting out will do it.
placing a comment after } along WITH proper indentation, can help with this problem.