Go语言的函数01---概念

package main

import "fmt"

/*
向某人致以问候
参数:
name string类型,要问候的对象
n	 int类型,要问候的次数
返回值:
	 string类型,对方的回复
*/

func SayHello(name string, n int) string {
	fmt.Println("亲爱的",name)
	for i:=0;i < n ; i++ {
		fmt.Println("向你致以节日的问候")
	}
	fmt.Println("bye!")
	return "谢谢!"
}

func main() {
	reply := SayHello("王尼玛", 3)
	fmt.Println(reply)
}

  

原文地址:https://www.cnblogs.com/yunweiqiang/p/11789051.html