I'm trying to wrap my head around multithreading, so I'm playing around with Fiber
s in Ruby. However, when I try to run my script, it tells me I have an unexpected newline character after my ternary statement. Did I miss something about the syntax, here?
timer = Fiber.new do |power|
power = power.nil? ? 'on' | power
start = Time.now
loop do
if power == 'off'
now = Time.now
puts now - start
end
power = Fiber.yield
end
end