Created
August 22, 2016 09:53
-
-
Save yanmhlv/59a205d899375f71532b83fc477bfce7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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