Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

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, and it can be received only once.

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

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

Ruby version changes

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