Go 系列教程 —— 5. 常量

guoxiaopang · 2017-12-07 07:06:56

const a="hello world"这种无类型的常量,可以当作c语言里的宏常量。

#9
更多评论

const hello = "Hello" fmt.Printf("type %T value %v", hello, hello)

输出: type string value Hello

常量仍然没有类型怎么理解?

#1

文中提到了:

> 无类型的常量有一个与它们相关联的默认类型,并且当且仅当一行代码需要时才提供它

#2