package main
import (
"fmt"
)
func main() {
//i := 5
//for i > 0 {
// i -= 1
// fmt.Println(i)
//}
str := "thankyouLORD"
for pos, char := range str {
fmt.Printf("Character on position %d is: %c \n", pos, char)
}
//min(7, 1, 9) //传递变长参数
//f1()
a()
callback(1, Add)
}
func Add(a, b int) {
fmt.Printf("The sum of %d and %d is: %d\n", a, b, a+b)
}
func callback(y int, f func(int, int)) {
f(y, 2) // this becomes Add(1, 2)
}
func a() {
i := 0
defer fmt.Println(i)
i++
return
}
func min(a ...int) { //传递变长参数
for _, v := range a {
fmt.Println(v)
}
}
func f1() {
fmt.Printf("-----------f1----------")
f2()
//defer f2()
fmt.Println()
fmt.Printf("--------------f1-1--------")
fmt.Println()
}
func f2() {
fmt.Printf("---------------f2--------------")
}
网友评论