Ian, continuation question -- does `type intElement list.Element(int)` introduce a new type just like `type myInt int` does? If so, in a previous example, these 2 maps are not of the same type, am I right?
Thank you very much, Andrey On Wednesday, July 1, 2020 at 10:50:07 AM UTC-6, Ian Lance Taylor wrote: > > On Wed, Jul 1, 2020 at 9:39 AM <aurelie...@gmail.com <javascript:>> > wrote: > > > > Is this expected? > > > > import "list" // for 'std' list.go2 > > > > func main() { > > type intElement list.Element(int) > > _ = make(map[int]intElement) // ok: compiles > > > > // nok > > _ = make(map[int]list.Element(int)) // cannot use generic type > list.Element(type TElem) without instantiation > > } > > > > I don't think it is, but in case it is, how would I instantiate a > make(map[int]intElement) without having to typedef a generic type before. > > From the parser's perspective the argument to make is an expression, > so in this case you need parentheses to keep this from looking like a > type conversion. > > make(map[int](list.Element(int))) > > Ian > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/651e60c9-323f-481a-8eb1-a15e20e0f68do%40googlegroups.com.