示例代碼packagemainimport("fmt""time")typenewFieldstringfunc(fnewField)print(){fmt.Println(f)}funcmain(){data:=[]newField{"one","two","thred"}for_,v:=rangedata{gov.print()//printonetwothreegofunc(){fmt.Println(v)}()//printthreethreethree}time.Sleep(3*time.Second)}疑問range過程中,兩種打印方式,為什么打印的結果不同呢?
小白,請教各位大佬!golang中range問題大佬們有什么好的建議?
翻閱古今
2019-09-13 09:52:58