如何理解go语言字符串不能修改
先来看一下官方对string
的定义:
// string is the set of all strings of 8-bit bytes, conventionally but not
// necessarily representing UTF-8-encoded text. A string may be empty, but
// not nil. Values of string type are immutable.
type string string
golang里面字符串是不能修改的,但是,如何理解呢?
比如:
s:="hello"
s="world"
s=s+"wprld"
上面代码都能修改呀?是哪里理解不对吗?
推荐文章: