Skip to content

Instantly share code, notes, and snippets.

@ryanwarsaw
Created May 27, 2017 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwarsaw/1f52d67847656822186525be03ae91fa to your computer and use it in GitHub Desktop.
Save ryanwarsaw/1f52d67847656822186525be03ae91fa to your computer and use it in GitHub Desktop.
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