るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

検索結果

Module#const_set(name, value) -> object (18137.0)

モジュールに name で指定された名前の定数を value とい う値として定義し、value を返します。

...た場合
Foo.const_set(:FOO, 123)
Foo::FOO # => 123

# Stringを指定した場合
Foo.const_set('BAR', 'abc')
Foo::BAR # => "abc"

# 既に定義されている定数の名前を指定した場合
Foo.const_set('BAR', '123')
# warning: already initialized constant Foo::BAR
# warning: previous defi...
...nition of BAR was here
# => "123"

# 不適切な定数名を指定した場合
Foo.const_set('foo', 1) # => NameError: wrong constant name foo
//}...

ruby 1.6 feature (138.0)

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

...が、この変更は元に戻りました。

p "#{ "" }"

=> ruby 1.6.7 (2002-03-01) [i586-linux]
""

=> -:1: warning: bad substitution in string
ruby 1.6.7 (2002-09-12) [i586-linux]
"#{ }"

=> ruby 1.6.7 (2002-09-25) [i586-linux]...
...gexp.quote("#")

p /a#{Regexp.quote("#")}b/x =~ "ab"

=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-03-01) [i586-linux]
"#"
0

=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-07-30) [i58...
...fatal)
from -:2
ruby 1.6.3 (2001-03-19) [i586-linux]

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

これらのメソッドが定数以外にアクセス可能になっていたバグが修正されました
((<ruby-dev:13019>))

: ((<Mar...