1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| package main
import "fmt"
func FuncName(arg1 int, arg2 int, arg3 string) int { switch arg3 { case "+": return arg1 + arg2 case "-": return arg1 - arg2 default: return 0 } }
func FuncDemo2(arg1, arg2 int, arg3 string) int { switch arg3 { case "+": return arg1 + arg2 case "-": return arg1 - arg2 default: return 0 } }
func FuncDemo3(arg1, arg2 int, arg3 string) (int, int, string) { return arg1, arg2, arg3 }
func FuncDemo4(arg1, arg2 int, arg3 string) (a, b int, c string) { a = arg1 b = arg2 c = arg3 return }
func main() { result := FuncName(5, 9, "+") result2 := FuncDemo2(9, 5, "-") fmt.Println(result, result2)
a, b, c := FuncDemo3(5,9,"*") fmt.Println(a, b, c)
d, e, f := FuncDemo4(5,6, "/") fmt.Println(d, e, f)
}
|