Sfoglia il codice sorgente

FIX 11.14.md

runtime error: index out of range when result len not enough
Ding 9 anni fa
parent
commit
4ec6a406d8
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      eBook/11.14.md

+ 1 - 1
eBook/11.14.md

@@ -162,7 +162,7 @@ func (cs Cars) FindAll(f func(car *Car) bool) Cars {
 
 // Process cars and create new data.
 func (cs Cars) Map(f func(car *Car) Any) []Any {
-       result := make([]Any, 0)
+       result := make([]Any, len(cs))
        ix := 0
        cs.Process(func(c *Car) {
            result[ix] = f(c)