2022-07-26: What does the following go code output? A: 5; B: hello; C: compile error; D: run error.
package main
import (
"fmt"
)
type integer int
func (i integer) String() string {
return "hello"
}
func main() {
fmt.Println(integer(5))
}
Answer 2022-07-26:
The answer is B. The String method of the interger is called, so it is hello. Don't be fooled by integer being an integer.