diff --git a/_content/tour/flowcontrol.article b/_content/tour/flowcontrol.article index 448cb76765..4d02cef7ef 100644 --- a/_content/tour/flowcontrol.article +++ b/_content/tour/flowcontrol.article @@ -153,7 +153,7 @@ This construct can be a clean way to write long if-then-else chains. * Defer -A defer statement defers the execution of a function until the surrounding +A `defer` statement defers the execution of a function until the surrounding function returns. The deferred call's arguments are evaluated immediately, but the function call diff --git a/_content/tour/flowcontrol/defer.go b/_content/tour/flowcontrol/defer.go index 3314c056d2..1ca70ae2d1 100644 --- a/_content/tour/flowcontrol/defer.go +++ b/_content/tour/flowcontrol/defer.go @@ -4,8 +4,13 @@ package main import "fmt" +func helper() string { + fmt.Println("helper") + return "world" +} + func main() { - defer fmt.Println("world") + defer fmt.Println(helper()) fmt.Println("hello") }