structs are mutable
This commit is contained in:
parent
5d7a4fd53b
commit
3babe35fcd
@ -34,4 +34,8 @@ func main() {
|
|||||||
// pointer will be automatically dereferenced.
|
// pointer will be automatically dereferenced.
|
||||||
sp := &s
|
sp := &s
|
||||||
fmt.Println(sp.age)
|
fmt.Println(sp.age)
|
||||||
|
|
||||||
|
// Structs are mutable.
|
||||||
|
sp.age = 51
|
||||||
|
fmt.Println(sp.age)
|
||||||
}
|
}
|
||||||
|
@ -5,3 +5,4 @@ $ go run structs.go
|
|||||||
&{Ann 40}
|
&{Ann 40}
|
||||||
Sean
|
Sean
|
||||||
50
|
50
|
||||||
|
51
|
||||||
|
Loading…
x
Reference in New Issue
Block a user