【Go Time】Go言語定数定義キーワードconst
926 ワード
func consts() {
const filename = "abc.txt"
const a, b = 3, 4
var c int
c = int(math.Sqrt(a*a + b*b))
fmt.Println(filename, c)
}
package main
const filename = "abc.txt"
const()
定義const (
filename = "abc.txt"
a, b = 3, 4
)
const a, b = 3, 4
var c int
//
c = int(math.Sqrt(a*a + b*b))
iota
自己付加価値const (
cpp = iota
_
python
golang
javascript
)
fmt.Println(cpp,python,golang,javascript) // 0 2 3 4
const (
b = 1 << (10 * iota)
kb
mb
gb
tb
pb
)
fmt.Println(b,kb,mb,gb,tb,pb)
// 1 1024 1048576 1073741824 1099511627776 1125899906842624