$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #224

What is the output?

for i := 0; i < 3; i++ {
	defer fmt.Print(i)
}
  1. 012
  2. 0
  3. 210
  4. 222
Deferred calls run last-in, first-out when the function returns, and each captured i at defer time.
Play Problem Solving ▸