3 ms·
> It is how container types are done in Go. You can't define your own compile type safe container types in Go at first place. You demonstrated nothing with you
by nostalgeek 8y ago
> It is how container types are done in Go.
You can't define your own compile type safe container types in Go at first place. You demonstrated nothing with your piece of code, you just wrote some dynamic stuff that doesn't care about types, this isn't a container type, you ignore the type of the element.
- daenz 8y ago>You demonstrated nothing with your piece of code I've demonstrated how you map a function over a list containing any type. How would you do it? Provide a solution.
- nostalgeek 8y ago> I've demonstrated how you map a function over a list containing any type. How would you do it? Provide a solution. you've demonstrated you are unable to do it while conserving the type of an element. You iterate over an array with a range loop which allows the code to stay compile time safe. That's the only thing one can call idiomatic go code here. You threw out compile time safety for nothing trying to prove some point that makes no sense to begin with.