A type assertion on a nil interface value will always ___.
- Panic
- Return nil
- Compile successfully
- Result in a runtime error
A type assertion on a nil interface value will always return nil. In Go, a nil interface does not hold any value or type, so any type assertion on a nil interface will return a nil value for the type being asserted. This behavior is a safe and predictable way to handle type assertions when the underlying interface is nil.
Loading...
Related Quiz
- What are the basic data types available in Go?
- Implementing the _____ HTTP method is crucial for allowing clients to delete resources.
- How does Go handle method resolution when multiple embedded interfaces have methods with the same name?
- What is the primary role of an HTTP handler in a Go web application?
- How would you implement a timeout using channels?