美文网首页
Go学习笔记-《TheGoProgrammingLanguage

Go学习笔记-《TheGoProgrammingLanguage

作者: 十旋转45度 | 来源:发表于2017-04-14 11:20 被阅读0次
(P4) 数组,String s的元素表达方式,[m,n)区间元素可表示为s[m:n]

For now, think of a slice as a dynamically size d sequence s of array elements where individual elements can be accessed as s[i] and a contiguous subsequence as s[m:n]. The number of elements is given by len(s).

(P4) 区间元素集表示,可以省略index,默认位置变为0(前位)和len(s)后位

If m or n is omitted, it defaults to 0 or len(s) respectively, so we can abbreviate the desired slice as os.Args[1:].

(P5) i++,i--但是没有--i, ++i

the y are postfix only, so --i is not legal

(P6) for循环条件语句不需要()包裹

The for loop is the only loop statement in Go. It has a number of for ms, one of which is illustrated here:


for initialization; condition; post {

// zero or more statements

}

P6)for语句的条件语句有缺省部分,对应的分号可以省略

Any of these parts may be omitted. If there is no initialization and no post, the semicolons may also be omitted:

// a traditional "while" loop

for condition {

// ...

}

If the con dition is omitted entirely in any of these for ms, for example in

// a traditional infinite loop

for {

// ...

}

相关文章

网友评论

      本文标题:Go学习笔记-《TheGoProgrammingLanguage

      本文链接:https://www.haomeiwen.com/subject/gsjwattx.html