ch12: fix code path

This commit is contained in:
chai2010
2016-01-20 22:56:40 +08:00
parent 617ef87432
commit 0c1b9762d9
7 changed files with 7 additions and 32 deletions

View File

@@ -22,9 +22,8 @@ e.args[0].value.y.value = "pi"
在可能的情況下你應該避免在一個包中暴露和反射相關的接口。我們將定義一個未導出的display函數用於遞歸處理工作導出的是Display函數它隻是display函數簡單的包裝以接受interface{}類型的參數:
<u><i>gopl.io/ch12/display</i></u>
```Go
gopl.io/ch12/display
func Display(name string, x interface{}) {
fmt.Printf("Display %s (%T):\n", name, x)
display(name, reflect.ValueOf(x))
@@ -224,5 +223,3 @@ c.Value = 42
**練習 12.1** 擴展Displayhans以便它可以顯示包含以結構體或數組作爲map的key類型的值。
**練習 12.2** 增強display函數的穩健性通過記録邊界的步數來確保在超出一定限製前放棄遞歸。在13.3節,我們會看到另一種探測數據結構是否存在環的技術。)