Intermediate
Go (Golang)
Q52 / 100
What is a closure in Go?
Correct! Well done.
Incorrect.
The correct answer is B) A function value that references variables from outside its body; the function may access and modify the referenced variables
B
Correct Answer
A function value that references variables from outside its body; the function may access and modify the referenced variables
Explanation
adder := func(x int) func() int { sum := 0; return func() int { sum += x; return sum } }(5) — the inner func closes over sum.
Progress
52/100