Beginner Go (Golang)
Q7 / 100

What does the defer keyword do?

Correct! Well done.

Incorrect.

The correct answer is B) Schedules a function call to run when the surrounding function returns

B

Correct Answer

Schedules a function call to run when the surrounding function returns

Explanation

defer f.Close() ensures f.Close() is called when the function exits. Deferred calls run in LIFO order.

Progress
7/100