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.
This commit is contained in:
Elias Kosunen 2017-06-09 23:30:42 +03:00 committed by GitHub
parent 6907911089
commit 7763b97b52

View File

@ -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;
}
}
// ...
}