A Tour of Go For is Go's "while"

At that point you can drop the semicolons(分号): C's while is spelled for in Go.

package main 

import "fmt"

func main() {
    sum := 1
    for sum < 1000 {
        sum += sum
    }
    fmt.Println(sum)
}

 

posted @ 2014-10-26 22:47  wuhn  阅读(137)  评论(0编辑  收藏  举报