Created
May 27, 2017 17:13
-
-
Save ryanwarsaw/1f52d67847656822186525be03ae91fa to your computer and use it in GitHub Desktop.
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
channel = Channel(String).new | |
# Sender: Sends random animal from array over the channel. | |
spawn do | |
loop do | |
animals = ["dog", "cat", "bird", "horse", "hamster", "rabbit", "deer", "squirrel", | |
"ground hog", "hawk", "flying squirrel", "pug", "fox", "coyote", "turtle"] | |
channel.send(animals[Random.new.rand(0..14)]) | |
end | |
end | |
spawn do | |
loop do | |
puts channel.receive | |
end | |
end | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment