Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fiber#alive? not defined

Tags:

ruby

fiber

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?

like image 253
sawa Avatar asked Mar 16 '11 16:03

sawa


People also ask

What are fiber good for?

Fiber is incredibly important. It leaves your stomach undigested and ends up in your colon, where it feeds friendly gut bacteria, leading to various health benefits (1). Certain types of fiber may also promote weight loss, lower blood sugar levels, and fight constipation (2).

What fruit is highest in fiber?

Raspberries win the fiber race at 8 grams per cup. Exotic fruits are also good sources of fiber: A mango has 5 grams, a persimmon has 6, and 1 cup of guava has about 9. Dark-colored vegetables. In general, the darker the color of the vegetable, the higher the fiber content.


1 Answers

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 
like image 82
John Feminella Avatar answered Sep 18 '22 14:09

John Feminella