Reputation: 12549
I want to extend the array type only when its elements is of a specific type. In this case I'm using instances of EKCalendar.
This does not work:
public extension Array where Generator.Element : EKCalendar{
}
But this Does:
public extension CollectionType where Generator.Element : EKCalendar{
}
Why is it I can only do this with a protocol ?
Upvotes: 1
Views: 94
Reputation: 2333
While extending Array
you cannot access Generator.Element
because it's part of the CollectionType
protocol, you need to use Element
:
public extension Array where Element: EKCalendar {
//....
}
Upvotes: 3