0
如何打印關閉捕獲的所有變量?例如:打印關閉捕獲的所有變量
func myScope() {
users := GetUsers("John")
services := GetServices("Movies")
allVariablesString := func() string {
return PrintAllCapturesWithoutSpecified()
}()
}
我打算利用這個想法,如果可能的話,將任何涉及的值記錄在錯誤範圍內,而無需手動指定每個變量。
你不能在運行時。如果沒有對它們的引用,編譯器可能甚至不會在範圍中包含變量。 – JimB
@JimB這很有道理。謝謝! – Steve