Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
而不是这样做,
@fiber = Fiber.new do # ... end
我正在尝试做这样的事情:
def test yield # ... end def create(process) @fiber = Fiber.new(process) end create(method(:test))
如何使Fiber代码看起来像已完成的部分?
Fiber
只需将方法转换为块:
def test Fiber.yield 2.71 Fiber.yield 3.14 Fiber.yield 42 end def create(&process) @fiber = Fiber.new(&process) end create(&method(:test)) @fiber.resume # => 2.71 @fiber.resume # => 3.14 @fiber.resume # => 42