I am currently in UCI Go Lang Course and Came across this function which the Syntax I did not understand. The function is directly from the example code, but has a syntax error I do not understand line 2 bracket. Also I come from JS, and C and Why in go are some functions declared without outer brackets?
func MakeDistOrigin(o_x, o_y float64)
func (float64, float64) float64 {
fn := func (x, y float64) float64 {
return math.Sqrt(math.Pow(x - o_x, 2) +
math.Pow(y - o_y, 2))
}
return fn
}
I expected this function to have outer brackets for each function and to return a function that then takes in another variable. Thanks!