golang - Why ++ and -- not work in expressions?

go

Solution

`++` and `--` are statements in golang, not expressions

Problem

What we take for granted in other languages and almost expect it to work in go, won't work - its almost so natural to do this, so why isn't the compiler happy? Just feeling like bailing out of go sometimes. The only way to increment the value is to put it in its own separate line? http://play.golang.org/p/_UnpZVSN9n ``` package main import "fmt" import "strconv" func main() { a := 1 //Evaluate expression and pass into function - won't work fmt.Println(strconv.Itoa(a++)) //Braces around a++ also won't work fmt.Println(strconv.Itoa((a++))) } ```

Original source

Related problems