Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-13 Thread Dave Reed via swift-users
Thanks to both of you for the follow-up. For my use, the class being final is probably ok. Dave Reed > On Jan 10, 2017, at 3:05 AM, Slava Pestov wrote: > >> >> On Jan 9, 2017, at 11:59 PM, Pierre Monod-Broca via swift-users >> wrote: >> >> Hi

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-10 Thread Slava Pestov via swift-users
> On Jan 9, 2017, at 11:59 PM, Pierre Monod-Broca via swift-users > wrote: > > Hi again, > > You might want to look at Self requirement in protocols for exemple: > protocol P { > func items(/*...*/) -> [Self] > } > class C: P { > func items(/*...*/) -> [C] { >...

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-10 Thread Pierre Monod-Broca via swift-users
Hi again, You might want to look at Self requirement in protocols for exemple: protocol P { func items(/*...*/) -> [Self] } class C: P { func items(/*...*/) -> [C] { ... } } However it might not always work as you expect. I can't say which is the better. Using associated type might be

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-05 Thread Pierre Monod-Broca via swift-users
Hello, It looks that you have what you wanted because Event.Entity is an alias of Event. Pierre > Le 5 janv. 2017 à 16:47, Dave Reed via swift-users a > écrit : > > Is there a way to make a static or class method specify the return type be > the actual class it is