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

functions _ golang

时间:2015-03-14 18:29:44      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:

Functions are central in Go. We‘ll learn about functions with a few different examples

package main

import (
    "fmt"
)

func plus(a int, b int) int {
    return a + b
}

func plusPlus(a, b, c int) int {
    return a + b + c
}

func main() {
    res := plus(1, 2)
    fmt.Println("1 + 2 = ", res)

    res = plusPlus(1, 2, 3)
    fmt.Println("1 + 2 + 3 = ", res)
}
1 + 2 =  3
1 + 2 + 3 =  6

总结 :

  1 : ......

functions _ golang

标签:

原文地址:http://www.cnblogs.com/jackkiexu/p/4337850.html

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