下列选项正确的是?
func main() {
str := "hello"
str[0] = 'x'
fmt.Println(str)
}
A. hello B. xello C. compilation error
参考代码及解析:C。
知识点:Go 语言中的字符串是只读的。
下列选项正确的是?
func main() {
str := "hello"
str[0] = 'x'
fmt.Println(str)
}
A. hello B. xello C. compilation error
参考代码及解析:C。
知识点:Go 语言中的字符串是只读的。