码迷,mamicode.com
首页 > 其他好文 > 详细

A Tour of Go Function values

时间:2014-10-28 00:39:13      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   java   sp   div   on   

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))
}

 

A Tour of Go Function values

标签:style   blog   io   color   ar   java   sp   div   on   

原文地址:http://www.cnblogs.com/ghgyj/p/4055518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!