Go语言中同时有函数和方法! 函数: go程序必须要包含一个main函数.main函数不能有任何参数和返回值! 1. 定义方法示例: func max(num1, num2 int) int { // 形参类型相同时,可以只写一个类型 // 后面的int代表返回值类型 /* 定义局部变量 */ var result int if (num1 > num2) { result = num1 } else { result = num2 } return result } -------------…
http://stackoverflow.com/questions/2529184/difference-between-method-and-function-in-scala A Function Type is (roughly) a type of the form (T1, ..., Tn) => U, which is a shorthand for the trait FunctionN in the standard library. Anonymous Functions a…