Skip to content

Commit 365fe3e

Browse files
authored
Merge pull request #85 from AndrewChan2022/main
typo of split to spilt
2 parents ec89adf + d14532e commit 365fe3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/cpp_tricks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ void calc_average() {
625625
例如字符串切片函数典型的一种实现中,因为“尾巴”的伺候和“主体”的伺候,就会产生重复代码:
626626

627627
```cpp
628-
vector<string> spilt(string str) {
628+
vector<string> split(string str) {
629629
vector<string> list;
630630
string last;
631631
for (char c: str) {
@@ -644,7 +644,7 @@ vector<string> spilt(string str) {
644644
上面的代码中重复的部分 `list.push_back(last);` 可以用 Lambda 复用,把重复的操作封装成局部的 Lambda:
645645
646646
```cpp
647-
vector<string> spilt(string str) {
647+
vector<string> split(string str) {
648648
vector<string> list;
649649
string last;
650650
auto push_last = [&] {

0 commit comments

Comments
 (0)