在做樹的遞歸遍歷按層遍歷的代碼的時候遇到一個問題就是這樣
var ff = func (int) {
ff()
}
上面的代碼編譯不過去纠俭。
查找資料是這么講的:
We've written >100k lines of Go code and it has come up maybe once. That kind of frequency doesn't suggest that a language change is warranted.
意思就是說府瞄,在實(shí)際編碼中遇到需要這種特性的幾率很小很小晾虑,所以沒有必要直接在語言層面去支持纹笼,如果偶然遇到就使用替代方案吧
當(dāng)然也是有替代方案的
type funcType func(int)
var f funcType
f = func(i int) {
f(i)
}