golang 常量的用法

1.Golang常量的用法

//常量的用法
    var num int
    num =9 
    
    //1.常量声明的时候必须赋值
    const tax int = 0
    
    //2.常量值是无法修改的
    //tax = 10
    
    //3.常量只能修饰bool,数值类型(int,float系列)、string类型
    
    //4.常量的自增
    const(
        a = iota
        b
        c
    )
    fmt.Println(a,b,c)  // 0 1 2

猜你喜欢

转载自www.cnblogs.com/tomtellyou/p/10464137.html