Re: access modifiers in protocols
Re: access modifiers in protocols
- Subject: Re: access modifiers in protocols
- From: Quincey Morris <email@hidden>
- Date: Wed, 17 Jun 2015 06:12:05 +0000
On Jun 16, 2015, at 22:37 , Roland King <email@hidden> wrote:
>
> No - can’t have a stored property in an extension
(Someone just asked basically the same question in the dev forums, but with a different example. Was that you?)
The following compiles for me without error:
> public protocol Foo {
> mutating func foo( Int )->Void
> }
>
> extension Foo {
> internal mutating func fooInternal( Int )->Void {}
> public mutating func foo( i: Int )->Void { fooInternal (i)}
> }
>
> internal protocol FooInternal: Foo {
> mutating func fooInternal( Int )->Void
> }
>
> internal protocol FooArray: FooInternal {
> var bar : Array<Int> { get set }
> }
>
> extension FooArray {
> mutating func fooInternal( i: Int )->Void { bar.append( i )}
> }
>
> public struct AFoo: Foo {
> public mutating func foo( Int )->Void { print ("cheers")}
> }
>
> public struct BFoo: Foo, FooArray {
> var bar : Array<Int> = []
> }
I’m not absolutely sure it does what you want, and if it does I’m not sure it’s the shortest possible sequence. But it compiles without error.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden