我试图在Go中声明为constant,但是它抛出一个错误。有人可以在Go中声明常量的语法帮助我吗?
这是我的代码:
const romanNumeralDict map[int]string = {
1000: "M",
900 : "CM",
500 : "D",
400 : "CD",
100 : "C",
90 : "XC",
50 : "L",
40 : "XL",
10 : "X",
9 : "IX",
5 : "V",
4 : "IV",
1 : "I",
}
这是错误
# command-line-arguments
./Roman_Numerals.go:9: syntax error: unexpected {
non-declaration statement outside function body
实际上这会在编译时抛出一个。怎么会?