|
@@ -69,7 +69,7 @@ allNewBMWs := allCars.FindAll(func(car *Car) bool {
|
|
|
4)我们也可以根据参数返回不同的函数。也许我们想根据不同的厂商添加汽车到不同的集合,但是这(这种映射关系)可能会是会改变的。所以我们可以定义一个函数来产生特定的添加函数和 map 集:
|
|
4)我们也可以根据参数返回不同的函数。也许我们想根据不同的厂商添加汽车到不同的集合,但是这(这种映射关系)可能会是会改变的。所以我们可以定义一个函数来产生特定的添加函数和 map 集:
|
|
|
|
|
|
|
|
```go
|
|
```go
|
|
|
-func MakeSortedAppender(manufacturers[]string)(func(car*Car),map[string]Cars) {
|
|
|
|
|
|
|
+func MakeSortedAppender(manufacturers []string)(func(car *Car),map[string]Cars) {
|
|
|
// Prepare maps of sorted cars.
|
|
// Prepare maps of sorted cars.
|
|
|
sortedCars := make(map[string]Cars)
|
|
sortedCars := make(map[string]Cars)
|
|
|
for _, m := range manufacturers {
|
|
for _, m := range manufacturers {
|