[swift-users] Extensions

Don Giovanni don-giovanni at hotmail.com
Sat May 13 19:32:17 CDT 2017


Hi I was wondering if i could get some suggestions on this:


extension CGPoint : Comparable

{

    static func <(l: CGPoint, r: CGPoint) ->

          Bool{

return true;

}

     static func ==(l: CGPoint, r: CGPoint) ->

           Bool{

       return true;

}

}


CGPoint is a Core graphics struct.

This code gives me an error "Declaration is only valid at file scope". However per swift documentation, I cannot add an access modifier to extensions that adopt protocols.   I was wondering if there is an elegant workaround for this limitation or if there's something I'm missing here.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170514/1c0ac4f7/attachment.html>


More information about the swift-users mailing list