A Tour of Go Function values

时间:2014-10-28 00:39:13   收藏:0   阅读:130

Functions are values too.

在函数式语言中中函数都是变量,比如在javascript中

 

package main 

import (
    "fmt"
    "math"
)

func main() {
    hypot := func(x,y float64) float64 {
        return math.Sqrt(x*x + y*y)
    }
    fmt.Println(hypot(3, 4))
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!