Go Example--常量

package main

import (
    "fmt"
    "math"
)

const s string = "constant" //定义字符串常量
func main()  {
    fmt.Println(s)
    const n = 50000000 //无类型常量
    const d = 3e20 /n  //float64常量
    fmt.Println(d)
    fmt.Println(int64(d))
    fmt.Println(math.Sin(n)) //调用math包中的Sin函数,函数第一个字符大写,说明是包外可见
}

猜你喜欢

转载自www.cnblogs.com/promenader/p/9778393.html
今日推荐