Skip to content

Instantly share code, notes, and snippets.

@rousan
Created May 3, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rousan/936142a4dcaa4d478ba0c9342ef7fcb6 to your computer and use it in GitHub Desktop.
Save rousan/936142a4dcaa4d478ba0c9342ef7fcb6 to your computer and use it in GitHub Desktop.
Execution order of Post Increment and Pre Increment operators
package main
func increment(x *int) {
*x = *x + 1
}
func main() {
x := 0
// Execution order of Post Increment operator
_ = x // returns current value of x
increment(&x) // increment x by 1
// Execution order of Pre Increment operator
increment(&x) // increment x by 1
_ = x // returns current value of x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment