This commit is contained in:
Loic Nageleisen 2015-08-03 13:50:05 +02:00
parent 1921f98e47
commit 5a968ac76c
11 changed files with 219 additions and 0 deletions

View file

@ -0,0 +1,18 @@
# https://gobyexample.com/channel-directions
require 'channel'
def ping(pings, msg)
pings << msg
end
def pong(pings, pongs)
msg = pings.recv
pongs << msg
end
pings = Channel.new(1)
pongs = Channel.new(1)
ping(pings, 'passed message')
pong(pings, pongs)
puts pongs.recv