Add braces to for loop in P.1 example

`for` with no `block-statement` as its `statement` is bad practice and should not be shown in an example. This example is meant to demonstrate code duplication and expessiveness, not to show poor usage of braces or lack thereof.
pull/957/head
Elias Kosunen 9 years ago committed by GitHub
parent 6907911089
commit 7763b97b52

@ -486,11 +486,12 @@ The second version leaves the reader guessing and opens more possibilities for u
cin >> val;
// ...
int index = -1; // bad
for (int i = 0; i < v.size(); ++i)
for (int i = 0; i < v.size(); ++i) {
if (v[i] == val) {
index = i;
break;
}
}
// ...
}

Loading…
Cancel
Save