码迷,mamicode.com
首页 > 其他好文 > 详细

A Tour of Go For

时间:2014-10-27 00:09:59      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   ar   java   for   strong   sp   

Go has only one looping construct, the for loop.

The basic for loop looks as it does in C or Java, except that the ( ) are gone (they are not even optional) and the { } are required.

package main 

import "fmt"

func main() {
    sum := 0
    for i := 0; i < 10; i++ {
        sum += i
    }
    fmt.Println(sum)
}

 

A Tour of Go For

标签:style   blog   color   io   ar   java   for   strong   sp   

原文地址:http://www.cnblogs.com/ghgyj/p/4052959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!