Skip to content

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

instance method

Thread#[]=

(::interned key, untyped value) -> untyped
thr[sym] = obj → obj

Attribute Assignment—Sets or creates the value of a fiber-local variable, using either a symbol or a string. Assigning nil deletes the variable.

See also Thread#[].

For thread-local variables, please see thread_variable_set and thread_variable_get.