Skip to content
instance method · added in Ruby 4.0

Ractor#value

() -> untyped
ractor.value → obj

Waits for ractor to complete and returns its value or raises the exception which terminated the Ractor. The termination value will be moved to the calling Ractor. Therefore, at most 1 Ractor can receive another ractor’s termination value.

Example
r = Ractor.new{ [1, 2] }
r.value #=> [1, 2] (unshareable object)

Ractor.new(r){|r| r.value} #=> Ractor::Error

Ruby version changes

  1. 4.0
See also #unmonitor #to_s also in 4.1