On Wed, May 23, 2018, 5:59 AM Sankar <sankar.curios...@gmail.com> wrote:
> Is there a way to use a slice as a key to a map ? If I try, I get a > compilation error: `invalid map key type`. > > I tried creating a custom type, which contains an array as the element. > However, I could not find out what method to implement for my custom > type(such as: func (i *myType) Equal(j *myType) bool ) that would make the > equality operator call this function. > > An example program, where I needed to use a slice/array as the key of a > map is also available at: https://play.golang.org/p/kXwAaHckL76 > > Is there a way (or alternate solutions) to use a slice as the map key ? > Use an array instead of a slice. An array has a fixed size and can be used as a key to a map https://play.golang.org/p/xxxmrwpx08A > Thanks. > > -- > 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. > -- 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.