Re:From Java to Go, and Back Again (2016)
by nostalgeek on Sunday June 24, 2018 @07:00AM
(#17386016)
> 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.
>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.
Re:From Java to Go, and Back Again (2016)
by nostalgeek on Monday June 25, 2018 @11:46AM
(#17393296)
> 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.
It is how container types are done in Go.