variable declared and not used in Go

huangapple go评论72阅读模式
英文:

variable declared and not used in Go

问题

在下面的代码中:

func PrimeF(n uint64) {
    var i, t uint64 = 2, 3

    for ; i < n; {
        if n%i == 0 {
            n /= i
        }
    }
}

为什么我会收到错误消息:"t declared and not used"(t已声明但未使用)?

英文:

In the following code:

func PrimeF(n uint64) {
var i,t uint64 = 2,3


for ; i &lt; n; {
	if n%i == 0 {
		n /= i
	}

   }
}

Why do I get the error message: "t declared and not used"?

答案1

得分: 7

因为你在这里声明了一个名为 t 的变量:

var i,t uint64 = 2,3

但是从未使用过该变量。

英文:

Because you declared a variable called t here:

var i,t uint64 = 2,3

but never used that variable.

huangapple
  • 本文由 发表于 2013年10月14日 20:46:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/19360588.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定