Reputation: 4439
Is it possible to include an OR operator in the key of a map? Eg.
Go:
var a = map[string]int{
"A1"|| "B1": 1,
"A2": 2,
}
Error:
invalid operation: "A1" || "B1" (operator || not defined on string)
Upvotes: 3
Views: 4241
Reputation: 6555
No, you cannot. The grammar is defined at http://golang.org/ref/spec#Composite_literals and does not include this feature. You will have to specify each key distinctly.
Upvotes: 8