Skip to content

Commit 2edf9c7

Browse files
committed
Use std::string{} constructor approach for string concatenation in twelve-days example
1 parent c58c572 commit 2edf9c7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

exercises/practice/twelve-days/.meta/example.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ std::string verse(int day) {
2323
if (i == day) {
2424
result += gifts[i];
2525
} else if (i == 1) {
26-
result += ", and ";
27-
result += gifts[i];
26+
result += std::string{", and "} + gifts[i];
2827
} else {
29-
result += ", ";
30-
result += gifts[i];
28+
result += std::string{", "} + gifts[i];
3129
}
3230
}
3331

0 commit comments

Comments
 (0)