Skip to content

Instantly share code, notes, and snippets.

@fossil12
Last active March 10, 2016 01:58
Show Gist options
  • Save fossil12/d6e367b49df866b920b0 to your computer and use it in GitHub Desktop.
Save fossil12/d6e367b49df866b920b0 to your computer and use it in GitHub Desktop.
How do you comment on if/else clauses in C (Objective-C, ...)?
/*
* Variant 1
*/
if (cond) {
// Description of condition holding in if
// code...
} else {
// Description of condition holding in else
// code...
}
/*
* Variant 2
*/
// Description of condition holding in if
if (cond) {
// code ...
// Description of condition holding in else
} else {
// code ...
}
/*
* Variant 3
*/
// Description of condition holding in if
if (cond) {
// code ...
} else { // Description of condition holding in else
// code ...
}
/*
* Variant 4
*/
if (cond) { // Description of condition holding in if
// code ...
} else { // Description of condition holding in else
// code ...
}
/*
* Variant 5?
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment