fix 2.4 collection types

This commit is contained in:
stanzhai
2014-06-15 09:27:29 +08:00
parent 4dc52f3174
commit 773f9909cd
2 changed files with 72 additions and 65 deletions

View File

@ -27,42 +27,59 @@ lifedim说他平时12点就会睡1点47分发给我校对后的文档。
全体人员名单(排名不分先后):
- numbbbbb
- coverxit
- wh1100717
- TimothyYe
- honghaoz
- Hawstein
- JaySurplus
- stanzhai
- lyuka
- geek5nan
- xielingwang
- yankuangshi
- dabing1022
- siemenliu
- fd5788
- youkugems
- haolloyin
- superkam
- vclwei
- sg552
- bzsy
- pyanfield
- ericzyh
- 088haizi
- viztor
- pp-prog
- baocaixiong
- marsprince
- shinyzhu
- happyming
- menlongsheng
- zq54zquan
- Evilcome
- lslxdx
- yeahdongcn
- zqp
- xiehurricane
- Jasonbroker
- aquaporcus
- [numbbbbb](https://github.com/numbbbbb)
- [stanzhai](https://github.com/stanzhai)
- [coverxit](https://github.com/coverxit)
- [wh1100717](https://github.com/wh1100717)
- [TimothyYe](https://github.com/TimothyYe)
- [honghaoz](https://github.com/honghaoz)
- [lyuka](https://github.com/lyuka)
- [JaySurplus](https://github.com/JaySurplus)
- [Hawstein](https://github.com/Hawstein)
- [geek5nan](https://github.com/geek5nan)
- [yankuangshi](https://github.com/yankuangshi)
- [xielingwang](https://github.com/xielingwang)
- [yulingtianxia](https://github.com/yulingtianxia)
- [twlkyao](https://github.com/twlkyao)
- [dabing1022](https://github.com/dabing1022)
- [vclwei](https://github.com/vclwei)
- [fd5788](https://github.com/fd5788)
- [siemenliu](https://github.com/siemenliu)
- [youkugems](https://github.com/youkugems)
- [haolloyin](https://github.com/haolloyin)
- [wxstars](https://github.com/wxstars)
- [IceskYsl](https://github.com/IceskYsl)
- [sg552](https://github.com/sg552)
- [superkam](https://github.com/superkam)
- [zac1st1k](https://github.com/zac1st1k)
- [bzsy](https://github.com/bzsy)
- [pyanfield](https://github.com/pyanfield)
- [ericzyh](https://github.com/ericzyh)
- [peiyucn](https://github.com/peiyucn)
- [sunfiled](https://github.com/sunfiled)
- [lzw120](https://github.com/lzw120)
- [viztor](https://github.com/viztor)
- [wongzigii](https://github.com/wongzigii)
- [umcsdon](https://github.com/umcsdon)
- [zq54zquan](https://github.com/zq54zquan)
- [xiehurricane](https://github.com/xiehurricane)
- [Jasonbroker](https://github.com/Jasonbroker)
- [tualatrix](https://github.com/tualatrix)
- [pp-prog](https://github.com/pp-prog)
- [088haizi](https://github.com/088haizi)
- [baocaixiong](https://github.com/baocaixiong)
- [yeahdongcn](https://github.com/yeahdongcn)
- [shinyzhu](https://github.com/shinyzhu)
- [lslxdx](https://github.com/lslxdx)
- [Evilcome](https://github.com/Evilcome)
- [zqp](https://github.com/zqp)
- [NicePiao](https://github.com/NicePiao)
- [LunaticM](https://github.com/LunaticM)
- [menlongsheng](https://github.com/menlongsheng)
- [lifedim](https://github.com/lifedim)
- [happyming](https://github.com/happyming)
- [bruce0505](https://github.com/bruce0505)
- [Lin-H](https://github.com/Lin-H)
- [takalard](https://github.com/takalard)
- [ChildhoodAndy](https://github.com/ChildhoodAndy)
- [marsprince](https://github.com/marsprince)

View File

@ -1,5 +1,5 @@
> 翻译zqp
> 校对shinyzhu
> 校对shinyzhu, stanzhai
# 集合类型 (Collection Types)
-----------------
@ -123,14 +123,8 @@ shoppingList[4...6] = ["Bananas", "Apples"]
// shoppingList 现在有六项
```
<<<<<<< HEAD
> 注意:
>我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行期错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。
=======
> 注意:
>
>我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行时错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。
>>>>>>> a516af6a531a104ec88da0d236ecf389a5ec72af
调用数组的`insert(atIndex:)`方法来在某个具体索引值之前添加数据项:
@ -364,6 +358,7 @@ for (airportCode, airportName) in airports {
// TYO: Tokyo
// LHR: London Heathrow
```
`for-in`循环请参见[For 循环](05_Control_Flow.html#for_loops)。
我们也可以通过访问它的`keys`或者`values`属性(都是可遍历集合)检索一个字典的键或者值:
@ -374,9 +369,7 @@ for airportCode in airports.keys {
}
// Airport code: TYO
// Airport code: LHR
```
```swift
for airportName in airports.values {
println("Airport name: \(airportName)")
}
@ -389,9 +382,7 @@ for airportName in airports.values {
```swift
let airportCodes = Array(airports.keys)
// airportCodes is ["TYO", "LHR"]
```
```swift
let airportNames = Array(airports.values)
// airportNames is ["Tokyo", "London Heathrow"]
```
@ -435,4 +426,3 @@ Swift 数组的可变性行为同时影响了数组实例如何被分配和修
> 注意:
> 在我们不需要改变数组大小的时候创建不可变数组是很好的习惯。如此 Swift 编译器可以优化我们创建的集合。