[swift-users] Extensions
Brent Royal-Gordon
brent at architechies.com
Sat May 13 20:32:21 CDT 2017
> On May 13, 2017, at 5:32 PM, Don Giovanni via swift-users <swift-users at swift.org> wrote:
>
> 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.
Is this the only thing in the file, or is the extension nested inside something else? That's what that error usually means.
--
Brent Royal-Gordon
Architechies
More information about the swift-users
mailing list