method
class_variable_set
ruby latest stable - Class:
Module
class_variable_set(p1, p2)public
Sets the class variable named by symbol to the given object. If the class variable name is passed as a string, that string is converted to a symbol.
class Fred @@foo = 99 def foo @@foo end end Fred.class_variable_set (:@@foo, 101) #=> 101 Fred.new .foo #=> 101
static VALUE
rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
{
ID id = id_for_var(obj, iv, a, class);
if (!id) id = rb_intern_str(iv);
rb_cvar_set(obj, id, val);
return val;
}