Created
June 6, 2016 06:46
-
-
Save scbizu/f55ba8991337372be1886c60c0f7f495 to your computer and use it in GitHub Desktop.
函数编程思维的闭包例子的Golang实现
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Studnet struct { | |
name string | |
age int | |
} | |
func Average(age int) func(stu *Studnet) bool { | |
return func(stu *Studnet) bool { | |
return stu.age > age | |
} | |
} | |
func main() { | |
Nace := &Studnet{"nace", 18} | |
Bizu := &Studnet{"Bizu", 20} | |
test := Average(19) | |
fmt.Println(test(Nace)) | |
fmt.Println(test(Bizu)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment