中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Go 語言函數(shù)作為實參

Go 函數(shù)Go 函數(shù)

Go 語言可以很靈活的創(chuàng)建函數(shù),并作為另外一個函數(shù)的實參。以下實例中我們在定義的函數(shù)中初始化一個變量,該函數(shù)僅僅是為了使用內置函數(shù) math.sqrt(),實例為:

實例

package main

import (
? ?"fmt"
? ?"math"
)

func main(){
? ?/* 聲明函數(shù)變量 */
? ?getSquareRoot := func(x float64) float64 {
? ? ? return math.Sqrt(x)
? ?}

? ?/* 使用函數(shù) */
? ?fmt.Println(getSquareRoot(9))

}

以上代碼執(zhí)行結果為:

3

Go 函數(shù)Go 函數(shù)

其他擴展