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

A Tour of Go Arrays

时间:2014-10-27 01:40:52      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   ar   sp   div   on   

The type [n]T is an array of n values of type T.

The expression

var a [10]int

declares a variable a as an array of ten integers.

An array‘s length is part of its type, so arrays cannot be resized. This seems limiting, but don‘t worry; Go provides a convenient way of working with arrays.

package main 

import "fmt"

func main() {
    var a [2]string
    a[0] = "Hello"
    a[1] = "World"
    fmt.Println(a[0], a[1])
    fmt.Println(a)
}

 

A Tour of Go Arrays

标签:des   style   blog   color   io   ar   sp   div   on   

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

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