Below code causes runtime panic on second Println if assertion fails and second value "OK" is not provided for assignment for return value. however, if the second value is provided runtime panic does not occur. How not assigning return value can cause the panic? is there any good resource to learn about panics in Go?
var i interface{} = "hello"
f, ok := i.(float64) // no runtime panic
fmt.Println(f, ok)
f = i.(float64) // panic
fmt.Println(f)
Update 1: To make the question more clear. I wanted to know how panic occurs at runtime when the second return value is not caught 'ok' and panic does not occur when the second return value is caught (f is assigned to zero value and ok is false)
Update 2: From the discussion I understood, assigning two return values handles the runtime panic, in short, it acts as a safeguard. Marking the answer as correct.