package main
import "fmt"
func main() {
const (
cpp = iota
java
python
php
javascript
)
fmt.Println(cpp,javascript,java,python,php)
}
- 如果我們不想要某個值咋寫呢?
package main
import "fmt"
func main() {
const (
cpp = iota
_
python
php
javascript
)
fmt.Println(cpp,javascript,python,php)
}
- 這樣
Java
就會被跳過了
package main
import "fmt"
func main() {
//b , kb , mb,gb ,tb,pb
const (
b = 1 << (10 * iota)
kb
mb
gb
tb
pb
)
fmt.Println(b , kb , mb,gb ,tb,pb)
}