Re: [go-nuts] Re: array indexed by derived type?

2018-10-07 Thread Ian Denhardt
Yeah, there's no way to do this as such. One thing you could possibly do instead is define a wrapper around the type and use methods: type MyWrapper struct { theSlice []Elem } type Index int func(w MyWrapper) At(i Index) Elem { return w.theSlice[int(i)] } func(w MyWrapper) SetAt(i

[go-nuts] Re: array indexed by derived type?

2018-10-07 Thread jake6502
I'm gonna say no. On Saturday, October 6, 2018 at 5:07:33 PM UTC-4, Steve Roth wrote: > > Is there a way to declare an array (or slice) that is indexed by a type > derived from int, rather than indexed by int? My intent is to have the > compiler complain if I index the array/slice with a