Merge pull request #161 from zouyx/master

因该方法为内部调用建议改为私有
This commit is contained in:
无闻
2015-10-26 10:17:20 -04:00
2 changed files with 10 additions and 10 deletions

View File

@@ -27,14 +27,14 @@ package main
import "fmt"
func main() {
x := Min(1, 3, 2, 0)
x := min(1, 3, 2, 0)
fmt.Printf("The minimum is: %d\n", x)
arr := []int{7,9,3,5,1}
x = Min(arr...)
x = min(arr...)
fmt.Printf("The minimum in the array arr is: %d", x)
}
func Min(a ...int) int {
func min(a ...int) int {
if len(a)==0 {
return 0
}

View File

@@ -11,17 +11,17 @@ package main
import "fmt"
func main() {
Function1()
function1()
}
func Function1() {
fmt.Printf("In Function1 at the top\n")
defer Function2()
fmt.Printf("In Function1 at the bottom!\n")
func function1() {
fmt.Printf("In function1 at the top\n")
defer function2()
fmt.Printf("In function1 at the bottom!\n")
}
func Function2() {
fmt.Printf("Function2: Deferred until the end of the calling function!")
func function2() {
fmt.Printf("function2: Deferred until the end of the calling function!")
}
```