Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-05 Thread Howard Waterfall
Updated sample On Sat, Jun 5, 2021 at 6:27 AM Howard Waterfall wrote: > Dammit!. How'd I miss that?! Thanks Dan. I updated the sample accordingly. > > On Fri, Jun 4, 2021, 9:10 PM Dan Kortschak wrote: > >> On Fri, 2021-06-04 at 20:29 -0700, Deiter wrote:

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-05 Thread Howard Waterfall
Dammit!. How'd I miss that?! Thanks Dan. I updated the sample accordingly. On Fri, Jun 4, 2021, 9:10 PM Dan Kortschak wrote: > On Fri, 2021-06-04 at 20:29 -0700, Deiter wrote: > > The reflect package provides the SetMapIndex method for updating > > elements in a map that are represented by a

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-06-04 at 20:29 -0700, Deiter wrote: > The reflect package provides the SetMapIndex method for updating > elements in a map that are represented by a reflect.Value type, but I > don’t see an equivalent for array/slice. > The sample app (link provided below) includes an example of map >

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Howard Waterfall
I'm trying to decouple algorithm from type. if an algorithm works on a collection, it ought to work on either a map or slice. It appeared that result.Value facilitated the decoupling entirely, until I ran into the limitation with array/slice. It seems odd that I have to use the unsafe the package

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Kurtis Rader
More context would be useful; i.e., what are you really trying to do and why? Such information often allows people to provide better answers; including whether this is an example of the [XY Problem]( https://xyproblem.info/) or you have a misunderstanding how slices work. Given your

[go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Deiter
The reflect package provides the SetMapIndex method for updating elements in a map that are represented by a reflect.Value type, but I don’t see an equivalent for array/slice. The sample app (link provided below) includes an example of map that’s been made accessible through a a