“declared and not used” Error

后端 未结 2 595
独厮守ぢ
独厮守ぢ 2020-12-19 02:49

I get this error saying that I\'m not using a variable… but to my noob eyes, it looks like I am:

func Sqrt(x float64) float64 {

    z := float64(x);
         


        
2条回答
  •  孤城傲影
    2020-12-19 03:25

    Here is another way to look at the function

    func Sqrt(x float64) (z float64) {
        z = x
        for i := 0; i < 10; i++ {
            z = z - (z*z - x)/(2*z);
        }
        return
    }
    

提交回复
热议问题