るりまサーチ

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

別のキーワード

  1. fileutils remove_dir
  2. fileutils remove_entry
  3. fileutils remove_file
  4. fileutils remove
  5. rexml/document remove

検索結果

Module#remove_const(name) -> object (18113.0)

name で指定した定数を取り除き、その定数に設定されていた値を 返します。

...定数がそのモジュールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
class Foo
FOO = 1
p remove_const(:FOO) # => 1
p FOO # => uninitialized constant FOO at Foo (NameError)
end
//}

組み込みクラス/モジュールを設定してい...
...指定した(まだロードしてない)定数を含めて削除する事ができます。

取り除かれた定数は参照できなくなりますが、消える訳ではないので注意して
使用してください。

@see Module#remove_class_variable, Object#remove_instance_variable...

Object#remove_instance_variable(name) -> object (6125.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...

Marshal フォーマット (66.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...設定しても dump されません。
Ruby 2.0 以降は freeze されているので、インスタンス変数は設定できません。

=== instance of the user class

==== String, Regexp, Array, Hash のサブクラス (インスタンス変数なし)

'C' で始まるデータ構造にな...
...ring, Regexp, Array, Hash のサブクラス (インスタンス変数あり)

'I' で始まるデータ構造になります。
d:marshal_format#instance_variableも参照してください。

//emlist[例 2: インスタンス変数あり][ruby]{
class Foo < Array # (or String, Regexp, Hash)
de...
...@bar = 1
end
p Bar.instance_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 }
# => n...

Ruby プログラムの実行 (30.0)

Ruby プログラムの実行 === Ruby プログラム

...ます。Module#module_eval/class_eval、
BasicObject#instance_eval
の三つだけが例外で、以下のように変更されます。

: Module#module_eval, Module#class_eval
self、class ともそのレシーバ
: BasicObject#instance_eval
self がそのレシーバ、class がそのレ...
...ム上にないなら例外 LocalJumpError
を発生します。

next ブロックの終わりまでジャンプ

retry 複雑だ…

==== eval, instance_eval, module_eval

これなんだっけ

=== 代入

代入とは、変数・定数のいずれかにオブジェクトを記憶させること...
...の class です。また非常に特殊な例外としてメソッド
Module#const_set によっても定義が可能です。さらに
Module#remove_const を使うことで定義の取り消しが可能です。

すでに定義されている定数の再定義および代入はできません。...

Module#remove_class_variable(name) -> object (12.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...

絞り込み条件を変える