Ordering the stack

Report a typo

Below you will see a small Go program that has multiple deferred fmt.Println() statements:

package main

import "fmt"

func main() {
    defer fmt.Println("3️⃣")
    defer fmt.Println("1️⃣")
    defer fmt.Println("2️⃣")
}

Deferred statements in Go are executed in a Last-In-First-Out (LIFO) order. Based on this premise, sort below the deferred fmt.Println() statements in the correct order they will be executed.

Put the items in the correct order
fmt.Println("1️⃣")
fmt.Println("2️⃣")
fmt.Println("3️⃣")
___

Create a free account to access the full topic