Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Module#remove_class_variable

remove_class_variable(sym) → obj

Removes the named class variable from the receiver, returning that variable’s value.

Example
class Example
  @@var = 99
  puts remove_class_variable(:@@var)
  p(defined? @@var)
end

produces:

Example
99
nil