so for this line:
func topSpeed<T: CollectionType where T.Generator: Flyable>(collection: T) -> Double {
collection.map { $0.airspeedVelocity }.reduce(0) { max($0, $1) }
I get this error:
error: cannot convert value of type '(_) -> _' to expected argument type '_ -> _'
collection.map { $0.airspeedVelocity }.reduce(0) { max($0, $1) }
I’m not sure how to fix that. I’m using swift 2.2/ Xcode 7.3 (7D715)
I like Blue 
ok I figured out my typo
:
func topSpeed<T: CollectionType where T.Generator.Element == Flyable>(c: T) -> Double {
return c.map { $0.airspeedVelocity }.reduce(0) { max($0, $1) }
}
works
:-X
1 Like
aestus
4
Code update for Swift 3.
In general, CollectionType is now Collection.
This is the code to make the Collection extension work:
extension Collection {
func skip(skip: Int) -> [Generator.Element] {
guard skip != 0 else { return [] }
var index = self.startIndex
var result: [Generator.Element] = []
var i = 0
repeat {
if i % skip == 0 {
result.append(self[index])
}
index = self.index(after: index)
i += 1
} while (index != self.endIndex)
return result
}
}
Also the part where you are making Bird conform to BooleanType doesn’t work. I could find a fix as both Bool and BooleanLiteralType aren’t protocols.
deng
5
Hi . do you remember NSRegularExpression Tutorial: Getting Started,
I updated to Swift 4 version.
Here is GitHub repo GitHub - BoxDengJZ/Swift4-NSRegularExpression-Tutorial-Getting-Started: Swift4 version updated :NSRegularExpression Tutorial: Getting Started.
If it is of use, a star is enough.
@aestus
This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!
1 Like