るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.033秒)
トップページ > クエリ:Kernel[x] > クエリ:const_defined?[x]

別のキーワード

  1. win32ole const_load
  2. module const_defined?
  3. _builtin const_defined?
  4. module const_set
  5. module const_get

ライブラリ

クラス

検索結果

Module#const_defined?(name, inherit = true) -> bool (18106.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
//}...

ruby 1.6 feature (12.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...def initialize(obj) @obj = obj end
def []=() @obj = obj end
def []() @obj end
end
module Kernel
def _ptr() Ptr.new(self) end
end

def foo(int)
int[] += 1
end
x = 1._ptr...
...ain) - -:2
-:2:in `sleep': Thread: deadlock (fatal)
from -:2
ruby 1.6.3 (2001-03-19) [i586-linux]

: ((<Module>))#const_defined?
: ((<Module>))#const_get
: ((<Module>))#const_set

これらのメソッドが定数以外にアクセス可能になっていたバグが...