If you are familiar with C99’s designated initializers, this is similar but less general and less confusing.
> On Jun 22, 2021, at 8:40 AM, Vaibhav Maurya <vaibhav.se...@gmail.com> wrote: > Hi, > > Please help me to understand the following syntax mentioned in the Golang > language specification document. > > https://golang.org/ref/spec#Composite_literals > > following is the search string for CTRL + F > // vowels[ch] is true if ch is a vowel \ > > Following declaration and initialization is confusing. > vowels := [128]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true, > 'y': true} > > Here one can see the vowels is an array. Where in the array initialization > syntax, there is a key value pair. I believe bool is the primitive type, so > the array values should be either true or false. > Why there are key value pair separated by colon in the initialization. > -- > 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/83571d7c-7dee-47f3-b105-4286320e88d6n%40googlegroups.com. -- 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/E7DEE768-5F85-4AE2-BDBD-830E8DBEA199%40iitbombay.org.