Created
December 11, 2015 19:51
-
-
Save pgburt/02d1d7f40034ecdbf39a to your computer and use it in GitHub Desktop.
Hey, I'm having some trouble understanding what's happening here.
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 | |
import "fmt" | |
func zeroval(ival int) { | |
ival = 0 | |
fmt.Println("ival:", ival) | |
} | |
func zeroptr(iptr *int) { | |
*iptr = 0 | |
} | |
func main() { | |
i := 1 | |
fmt.Println("initial:", i) | |
zeroval(i) | |
fmt.Println("zeroval:", i) | |
zeroptr(&i) | |
fmt.Println("zeroptr:", i) | |
fmt.Println("pointer:", &i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment