structs are mutable

This commit is contained in:
Mark McGranaghan 2012-10-24 09:50:01 -04:00
parent 5d7a4fd53b
commit 3babe35fcd
2 changed files with 5 additions and 0 deletions

View File

@ -34,4 +34,8 @@ func main() {
// pointer will be automatically dereferenced.
sp := &s
fmt.Println(sp.age)
// Structs are mutable.
sp.age = 51
fmt.Println(sp.age)
}

View File

@ -5,3 +5,4 @@ $ go run structs.go
&{Ann 40}
Sean
50
51