Created
January 30, 2014 08:49
-
-
Save zeekay/8704792 to your computer and use it in GitHub Desktop.
Python vs Go round 1.
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
package main | |
import "fmt" | |
func ping(c chan string) { | |
for { | |
c <- "ping" | |
} | |
} | |
func main() { | |
c := make(chan string) | |
go ping(c) | |
for p := range c { | |
fmt.Println(p) | |
} | |
} |
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
def ping(): | |
while True: | |
yield "ping" | |
for p in ping(): | |
print p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment