Merge pull request #310 from huangqiaobo/develop

fix some typos
This commit is contained in:
梁杰
2014-09-06 09:29:02 +08:00

View File

@ -682,10 +682,10 @@ protocolValue.simpleDescription
在尖括号里写一个名字来创建一个泛型函数或者类型。
```swift
func repeat<ItemType>(item: ItemType, times: Int) -> ItemType[] {
var result = ItemType[]()
for i in 0..times {
result += item
func repeat<ItemType>(item: ItemType, times: Int) -> [ItemType] {
var result = [ItemType]()
for i in 0..<times {
result.append(item)
}
return result
}
@ -707,7 +707,7 @@ possibleInteger = .Some(100)
在类型名后面使用`where`来指定对类型的需求,比如,限定类型实现某一个协议,限定两个类型是相同的,或者限定某个类必须有一个特定的父类
```swift
func anyCommonElements <T, U where T: Sequence, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element> (lhs: T, rhs: U) -> Bool {
func anyCommonElements <T, U where T: SequenceType, U: SequenceType, T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element> (lhs: T, rhs: U) -> Bool {
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {