Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Module#class_variable_get

mod.class_variable_get(symbol) → obj
mod.class_variable_get(string) → obj

Returns the value of the given class variable (or throws a NameError exception). The @@ part of the variable name should be included for regular class variables. String arguments are converted to symbols.

Example
class Fred
  @@foo = 99
end
Fred.class_variable_get(:@@foo)     #=> 99