Say I have next c program:
#include <stdio.h>
int main(int args, char* argv[])
{
enum RC {
APPLE=0,
ORANGE,
PEAR,
BANANA=99,
GRAPE
};
printf("%d, %d, %d, %d, %d\n", APPLE, ORANGE, PEAR, BANANA, GRAPE);
}
The output is:
0, 1, 2, 99, 100
If in go, how can I use a more golang way
to handle that?
In fact, if I just want to skip some value. e.g. print 0, 1, 2, 5, 6
, then I can use next to skip some value, but here I need to skip 96 values...
package main
import "fmt"
func main() {
const (
APPLE = iota
ORANGE
PEAR
_
_
BANANA
GRAPE
)
fmt.Println(APPLE, ORANGE, PEAR, BANANA, GRAPE)
}
And, also I can use next, but I still have many const variable after GRAPE
...
package main
import "fmt"
func main() {
const (
APPLE = iota
ORANGE
PEAR
BANANA = 99
GRAPE = 100
)
fmt.Println(APPLE, ORANGE, PEAR, BANANA, GRAPE)
}
So, is there any more golang way
for me to handle such kind of situation?