golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.55k stars 519 forks source link

tour: add brief explanation for defer #562

Open nbn opened 6 years ago

nbn commented 6 years ago

Context: https://tour.golang.org/flowcontrol/12

Adding a small paragraph about when defer is useful might make it Easier to understand. Especially why the Args Are not lazy evaluated too.

bgadrian commented 6 years ago

Related but not quite the same problem: https://github.com/golang/tour/issues/382

I suspect it is a powerful feature, specific to Go and the example is too simplistic.

Although the next page solve part of your problem, it uses Lazy args but it doesn't explain why and how.