此处已在Go
中出现过几次,但我认为我的经验是独一无二的。这是我的代码。声明变量并且未在for循环中使用
type Stack []Weight
func newStack(size int, startSpread Spread) Stack {
stack := make(Stack, size)
for _, curWeight := range stack {
curWeight = Weight{ startSpread, rand.Float64(), rand.Float64() }
}
return stack
}
为什么gc
告诉我,我没有使用curWeight
?
同样,for语句可以是'for i:= range stack {...} – 2011-06-10 04:27:44