I have a simple function which tests whether a string is an integer
func testInt(str string, m map[bool]) int {
_,e := strconv.ParseInt(str, 0, 64);
return m[nil == e] * 7;
}
where the map being passed contains m[true] = 1
, m[false] = 0
. However, when I attempt to run this Go complains
1: syntax error: unexpected )
Either I cannot pass maps around as parameters in this way or else I am doing this entirely wrong. In any case, I would much appreciate some help
A map
maps keys to values, using the syntax
map[KeyType]ValueType
(see https://blog.golang.org/go-maps-in-action)
In your function, you have not specified a ValueType
, causing this syntax error. It looks like you want a map[bool]int
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With