1

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 ?

1 Answer 1

3

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 {
   //....
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.