On Feb 4, 2016, at 4:56 PM, Charles Jenkins wrote:

Supposedly in a protocol, “Self” is the class implementing the protocol. So it seems to me that extension methods should be able to have a return type of Self so they can return self, and thus have the extension method behave the same as it would as if it were defined in the class adopting the protocol.

I am not sure if this solves your particular problem, but in general you must do this

protocol MyProtocol
        {
        typealias Element
        }

extension MyProtocol where Element == Self
        {

        // use Element instead of Self
        }

At least I have found this to work better in my use cases.

Jan E.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to