?
This document uses PHP Chinese website manual Release
Go 語言可以很靈活的創(chuàng)建函數(shù),并作為值使用。以下實例中我們在定義的函數(shù)中初始化一個變量,該函數(shù)僅僅是為了使用內(nèi)置函數(shù) math.sqrt() ,實例為:
package main import ( "fmt" "math" ) func main(){ getSquareRoot := func(x float64) float64 { return math.Sqrt(x) } fmt.Println(getSquareRoot(9)) }
以上代碼執(zhí)行結(jié)果為:
3
關(guān)于我們 聯(lián)系我們 留言板
手冊網(wǎng)