I\'d like to use the Accelerate framework to extend [Float] and [Double] but each of these requires a different implementation.
I tried the obvious:
If you want to extend only array with specific type. You should extend _ArrayType protocol.
extension _ArrayType where Generator.Element == Int {
func doSomething() {
...
}
}
If you extend Array
you can only make sure your element is conformed some protocol else. i.e:
extension Array where Element: Equatable {
func doSomething() {
...
}
}
Updated: With Swift 3.1 https://github.com/apple/swift/blob/master/CHANGELOG.md
extension Array where Element == Int {
func doSomething() {
...
}
}