Hello All,

The below statement does not compile in Go language. The compilation error 
is "syntax error: unexpected ++ at end of statement"

return *s++

The function containing this statement is as below

func Incr(s *int) int {
return *s++ //the purpose is to increment the parameter passed by 1. 
}

If I split the problematic statement as below I get the result I want.  

*s++
return *s

I read some material in which it is stated that ++ and -- are statements 
not expressions (Please refer the question " Why are ++ and -- are 
statements and not expressions ? " in URL 
"https://golang.org/doc/faq#inc_dec";). Can somebody help in understanding 
this..?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to