Created
May 3, 2018 11:08
-
-
Save rousan/936142a4dcaa4d478ba0c9342ef7fcb6 to your computer and use it in GitHub Desktop.
Execution order of Post Increment and Pre Increment operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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