I mean, it doesn't have to be I just find that it is more cleaner...
What happens now  - Init is not in the interface and I have to do type 
assertion every time I call to Init - That is for each class implementing 
the Runner interface.
It's a bit ugly in my POV But  I can live with it..

On Thursday, April 26, 2018 at 8:16:30 PM UTC+3, simon place wrote:
>
> does the init NEED to be in the interface?
>
> On Thursday, 26 April 2018 17:55:07 UTC+1, Nimrod Shneor wrote:
>>
>> Hey everyone,
>> I've encountered a design issue - 
>> I have an the following interface -
>>
>> type Runner interface {
>>   Run(x X,y Y)
>> }
>>
>> I want to add to it an Init(...) method which will initialize the 
>> internal fields of the Runner before performing `Run`..
>> My issue is that different structs implementing the `Runner` interface 
>> require different fields in order to initialize, How should I solve this?
>>
>> Thanks a lot!
>> Nimrod.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to