Re: [go-nuts] Re: Give us const arrays please :)
Thanks for the information. I did not know that. It's good to learn something new. :) On Monday, April 12, 2021 at 7:17:05 PM UTC+7 wagner riffel wrote: > On Mon Apr 12, 2021 at 5:04 AM -03, Henry wrote: > > The example you gave is actually a map[rune]bool in Go, and not an > > array. I > > It's a Go array in form of a composite literal, see > https://golang.org/ref/spec#Composite_literals > > -- 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/176fad1a-38a8-4e3f-ae0e-f2c435cb1688n%40googlegroups.com.
Re: [go-nuts] Re: Give us const arrays please :)
On Mon Apr 12, 2021 at 5:04 AM -03, Henry wrote: > The example you gave is actually a map[rune]bool in Go, and not an > array. I It's a Go array in form of a composite literal, see https://golang.org/ref/spec#Composite_literals -- 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/CALQL1TE71G0.1BJM6NT7DTW7W%40pampas.
[go-nuts] Re: Give us const arrays please :)
The example you gave is actually a map[rune]bool in Go, and not an array. I don't think C's array work like that too. I think you are confusing Go with other languages. In addition, arrays are rarely used in Go. Many people prefer using slices. On Monday, April 12, 2021 at 6:33:47 AM UTC+7 vladimi...@mail.ru wrote: > Hi Go-Masters > > It will be very useful to get constant arrays in Golang. > Programmers asked about it for years . > > For now we all should write not exported array definitions > and exported functions to get read access to it. > > *What we need* > const *M*yArray = [n]T = {...} or initMyArrayFunc() > > *What we have* > // --- > var ws = [256]bool{' ': true, '\t': true, '\n\: true, '\r\: true} > // IsWhitespace checks > func IsWhitespace(c byte) bool { > return whitespace[c] > } > // --- > var letter = [256]bool{ > 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, > ... > } > // IsLetterASCII checks a start of an ASCII identifier > func IsLetterASCII(c byte) bool { > return letter[c] // 'A'-'Z', 'a'-'z', '_' > } > and so on ... > > > > -- 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/39ee0315-2cde-4f62-98d4-4f6dbe6714e2n%40googlegroups.com.