Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Ractor.shareable?
(untyped obj) -> bool
Ractor.shareable?(obj) → true | false
ractor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/ractor.rb, line 438
def self.shareable? obj
__builtin_cexpr! %q{
RBOOL(rb_ractor_shareable_p(obj));
}
end
Checks if the object is shareable by ractors.
Example
Ractor.shareable?(1) #=> true -- numbers are shareable Ractor.shareable?('foo') #=> false, unless the string is frozen due to # frozen_string_literal: true Ractor.shareable?('foo'.freeze) #=> true
See also the “Shareable and unshareable objects” section in the Ractor class docs.