Sometimes the defer statement can include a lot of actions. In this case, it is advisable to use an anonymous function as a defer statement. You have a code:
package main
import "fmt"
func main() {
defer fmt.Println("action 1")
defer fmt.Println("action 2")
}
You need to order the lines of code below to represent the above program using an anonymous function. For this task, pay attention to the indents of the code. One indent is one tab space.
For simplicity, the
package main and import "fmt" statements have been omitted in the code you need to order below.Tip: Remember about the stack of defer statements.