Skip to content

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

instance method

Module#class_variable_defined?

(::interned arg0) -> bool
obj.class_variable_defined?(symbol) → true or false
obj.class_variable_defined?(string) → true or false

Returns true if the given class variable is defined in obj. String arguments are converted to symbols.

Example
class Fred
  @@foo = 99
end
Fred.class_variable_defined?(:@@foo)    #=> true
Fred.class_variable_defined?(:@@bar)    #=> false