11件ヒット
[1-11件を表示]
(0.047秒)
別のキーワード
クラス
- Module (11)
検索結果
-
Module
# const _ defined?(name , inherit = true) -> bool (18108.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...module Kernel
FOO = 1
end
# Object は include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true
module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defined?(:BAR)......# => true
class Baz
include Bar
end
# Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true
# 第二引数を false にした場合
p Baz.const_defined?(:BAR, false) # => false
//}...