66件ヒット
[1-66件を表示]
(0.014秒)
トップページ > :remove_const
別のキーワード
種類
- インスタンスメソッド (33)
- 文書 (22)
- 関数 (11)
ライブラリ
- ビルトイン (33)
キーワード
- Marshal フォーマット (11)
- Ruby プログラムの実行 (11)
-
rb
_ mod _ remove _ const (11) -
remove
_ class _ variable (11) -
remove
_ instance _ variable (11)
検索結果
先頭5件
-
Module
# remove _ const(name) -> object (18107.0) -
name で指定した定数を取り除き、その定数に設定されていた値を 返します。
...定数がそのモジュールやクラスに定義されていない場合に発生します。
//emlist[例][ruby]{
class Foo
FOO = 1
p remove_const(:FOO) # => 1
p FOO # => uninitialized constant FOO at Foo (NameError)
end
//}
組み込みクラス/モジュールを設定してい... -
VALUE rb
_ mod _ remove _ const(VALUE mod , VALUE name) (6100.0) -
-
Marshal フォーマット (24.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...tance_eval { @bar } # => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Bar, f)
end
# 別プログラム相当にするため remove_const
Object.send :remove_const, :Bar
module Bar
end
p bar = Marshal.load(File.binread('testfile'))
p bar.instance_eval { @bar }
# => nil
//}
//emlist[例 3:......end
end
p Baz.baz
# => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Baz, f)
end
# 別プログラム相当にするため remove_const
Object.send :remove_const, :Baz
module Baz
def self.baz
@@baz
end
end
p baz = Marshal.load(File.binread('testfile'))
# => Baz
baz.baz
# => uniniti... -
Module
# remove _ class _ variable(name) -> object (6.0) -
引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。
...ールやクラスに定義されていない場合に発生します。
//emlist[例][ruby]{
class Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}
@see Module#remove_const, Object#remove_instance_variable... -
Object
# remove _ instance _ variable(name) -> object (6.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...ない場合に発生します。
//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remove_instance_variable(:@foo) #=> 1
p remove_instance_variable(:@foo) # instance variable @foo not defined (NameError)
end
end
Foo.new.foo
//}
@see Module#remove_class_variable,Module#remove_const... -
Ruby プログラムの実行 (6.0)
-
Ruby プログラムの実行 === Ruby プログラム
...の class です。また非常に特殊な例外としてメソッド
Module#const_set によっても定義が可能です。さらに
Module#remove_const を使うことで定義の取り消しが可能です。
すでに定義されている定数の再定義および代入はできません。...