Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Moduleクラス > class_variable_defined?

instance method Module#class_variable_defined?

class_variable_defined?(name) -> bool

name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。

[PARAM] name:
SymbolString を指定します。
class Fred
  @@foo = 99
end
Fred.class_variable_defined?(:@@foo)    #=> true
Fred.class_variable_defined?(:@@bar)    #=> false
Fred.class_variable_defined?('@@foo')    #=> true
Fred.class_variable_defined?('@@bar')    #=> false
class Module