I have been working on Go for last 6-7 months now and I started reading Go docs in depth recently.
I came across a section on Functions. I have normally used functions with proper parameters and variadic params too. But, I haven’t used functions in following format:
The second param is _ which I do not know what it mean here. I know we use _ with range or with multiple returns but I am confused to see this in functions. Could anyone please give me an example of this and explain a bit?
B) func(int, int, float64) (float64, *[]int)
No variable names??
Also, in Map section, I am looking for an example for the following:
map[*T]struct{ x, y float64 }
So far, I have used maps with int or string types only.
a) function requires 3 arguments, but middle one is ignored, so not used in the function body. It is maybe made to satisfy some interface or maybe just a bad signature.
b) This is just signature. You probably found it in some interface definition. You don’t need variable names there, just types.
c) Just a map of structs. You can have maps of any type.