Skip to content
class method

Ractor.shareable?

(untyped obj) -> bool
Ractor.shareable?(obj) → true | false

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.

See also .select .shareable_lambda .recv .shareable_proc also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0