Update 22_Protocols.md (#685)

改正示例代码中的两处错误
This commit is contained in:
从今以后
2017-02-17 10:11:17 +08:00
committed by 安正超
parent ef7dc20a57
commit 80e357c01c

View File

@ -737,8 +737,8 @@ for object in objects {
```swift ```swift
@objc protocol CounterDataSource { @objc protocol CounterDataSource {
optional func incrementForCount(count: Int) -> Int @objc optional func incrementForCount(count: Int) -> Int
optional var fixedIncrement: Int { get } @objc optional var fixedIncrement: Int { get }
} }
``` ```
@ -886,10 +886,10 @@ extension PrettyTextRepresentable {
例如,你可以扩展 `CollectionType` 协议,但是只适用于集合中的元素遵循了 `TextRepresentable` 协议的情况: 例如,你可以扩展 `CollectionType` 协议,但是只适用于集合中的元素遵循了 `TextRepresentable` 协议的情况:
```swift ```swift
extension CollectionType where Generator.Element: TextRepresentable { extension Collection where Iterator.Element: TextRepresentable {
var textualDescription: String { var textualDescription: String {
let itemsAsText = self.map { $0.textualDescription } let itemsAsText = self.map { $0.textualDescription }
return "[" + itemsAsText.joinWithSeparator(", ") + "]" return "[" + itemsAsText.joined(separator: ", ") + "]"
} }
} }
``` ```