在函数范围内部和外部定义的常量之间是否存在差异(主要是性能)?
func (this *Person) SetDefaults() *Person{
const (
defaultFirstName = "first"
defaultLastName = "last"
)
//do stuff with constants
return this
}
Run Code Online (Sandbox Code Playgroud)
与
const (
defaultFirstName = "first"
defaultLastName = "last"
)
func (this *Person) SetDefaults() *Person{
//do stuff with constants
return this
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
66 次 |
| 最近记录: |