Skip to content

Instantly share code, notes, and snippets.

@yanmhlv
Created August 22, 2016 09:53
Show Gist options
  • Save yanmhlv/59a205d899375f71532b83fc477bfce7 to your computer and use it in GitHub Desktop.
Save yanmhlv/59a205d899375f71532b83fc477bfce7 to your computer and use it in GitHub Desktop.
func yield(count int) chan int {
ch := make(chan int)
go func() {
for i := 0; i < count; i++ {
ch <- i
}
close(ch)
}()
return ch
}
for i := range yield(10) {
println(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment