Skip to content
Quiz · Interfaces · lesson 8 of 10

Quiz — a nil pointer in a type switch

What does the program print?

GO
package main

import "fmt"

func main() {
    var p *int
    var v any = p
    switch x := v.(type) {
    case nil, *int:
        fmt.Println(x == nil)
    }
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way