structs are mutable
This commit is contained in:
parent
5d7a4fd53b
commit
3babe35fcd
@ -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)
|
||||
}
|
||||
|
@ -5,3 +5,4 @@ $ go run structs.go
|
||||
&{Ann 40}
|
||||
Sean
|
||||
50
|
||||
51
|
||||
|
Loading…
x
Reference in New Issue
Block a user