mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
FIX 11.14.md
runtime error: index out of range when result len not enough
This commit is contained in:
@@ -162,7 +162,7 @@ func (cs Cars) FindAll(f func(car *Car) bool) Cars {
|
|||||||
|
|
||||||
// Process cars and create new data.
|
// Process cars and create new data.
|
||||||
func (cs Cars) Map(f func(car *Car) Any) []Any {
|
func (cs Cars) Map(f func(car *Car) Any) []Any {
|
||||||
result := make([]Any, 0)
|
result := make([]Any, len(cs))
|
||||||
ix := 0
|
ix := 0
|
||||||
cs.Process(func(c *Car) {
|
cs.Process(func(c *Car) {
|
||||||
result[ix] = f(c)
|
result[ix] = f(c)
|
||||||
|
Reference in New Issue
Block a user