Quiz: Deduce the Outputs
Explore and assess your knowledge of Go interfaces, reflection, type assertions, and type switches by attempting to deduce the outputs in this quiz. This lesson helps reinforce your grasp of these key concepts before moving on to detailed exploration of reading and writing with interfaces.
We'll cover the following...
We'll cover the following...
Choose one possible correct answer
1.
Deduce the output of the following program:
package main
import "fmt"
type Any interface {}
type Anything struct {}
func main() {
any := getAny()
if any == nil {
fmt.Println("any is nil")
} else {
fmt.Println("any is not nil")
}
}
func getAny() Any {
return getAnything()
}
func getAnything() *Anything {
return nil
}
A.
any is nil
B.
any is not nil
C.
Compiler Error
D.
any is nil any is not nil
1 / 3
...