Go语言的“++”和“—”运算符

以下摘自The Go Programming Language

The increment statement i++ adds 1 to i ; it’s equivalent to i += 1 which is in turn equivalent to i = i + 1 . There’s a corresponding decrement statement i– that subtracts 1. These are statements, not expressions as the y are in most languages in the C family, so j = i++ is illegal, and the y are postfix only, so –i is not legal either.

要注意,i++i--Go语言中是语句,不是表达式,因此不能赋值给另外的变量。此外没有++i--i

 

发表评论

邮箱地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.