Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _content/tour/flowcontrol.article
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion _content/tour/flowcontrol/defer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}