Unclear about type assertion in pointer example

master
Patrick Mylund Nielsen 13 years ago
parent c6060554ee
commit 88b75b4791

@ -61,13 +61,13 @@ Usage:
c.Set("foo", foo, 0)
...
x, _ := c.Get("foo")
foo := x.(MyStruct)
foo := x.(*MyStruct)
fmt.Println(foo.Num)
...
foo.Num++
...
x, _ := c.Get("foo")
foo := x.(MyStruct)
foo := x.(*MyStruct)
foo.Println(foo.Num)
// will print:

@ -72,13 +72,13 @@ import (
// c.Set("foo", foo, 0)
// ...
// x, _ := c.Get("foo")
// foo := x.(MyStruct)
// foo := x.(*MyStruct)
// fmt.Println(foo.Num)
// ...
// foo.Num++
// ...
// x, _ := c.Get("foo")
// foo := x.(MyStruct)
// foo := x.(*MyStruct)
// foo.Println(foo.Num)
//
// will print:

Loading…
Cancel
Save