Question
I use ruby1.9.2p180 (2011-02-18 revision 30909) i686-linux. Fiber#alive?
returns an undefined error:
fiber = Fiber.new{puts 'hello'}
fiber.alive?
=> undefined error
Other methods, for example, Fiber#resume
, Fiber.yield
seem to be working fine. What is wrong?
By the way, what is the difference between Fiber#resume
and Fiber#transfer
?
Solution
You forgot to require 'fiber'
first:
f = Fiber.new { puts 'hello' }
=> #<Fiber:0x896109c>
f.alive?
# NoMethodError: undefined method `alive?' for #<Fiber:0x896109c>
# from (irb):2
# from /home/johnf/.rvm/rubies/ruby-1.9.2-rc1/bin/irb:17:in `<main>'
require 'fiber'
=> true
f.alive?
=> true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow