Explorar o código

FIX 11.14.md

runtime error: index out of range when result len not enough
Ding %!s(int64=9) %!d(string=hai) anos
pai
achega
4ec6a406d8
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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)