Question from the Go test

Type assertion in Go: what happens when asserting an incorrect type?

Waiting for validation

Consider the following Go code:

package main
import "fmt"

func main() {
var x interface{}
x = 10
y := x.(int)
fmt.Println(y)
x = "golang"
z := x.(int)
fmt.Println(z)
}

Author: W3D TeamStatus: Waiting for validationQuestion not yet passed
0
Community EvaluationsNo one has reviewed this question yet, be the first!