るりまサーチ

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

別のキーワード

  1. fileutils remove_file
  2. fileutils remove_entry
  3. fileutils remove_dir
  4. fileutils remove
  5. fileutils remove_entry_secure

ライブラリ

クラス

検索結果

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

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

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

@param name String または Symbol を指定します。

@return 引数で指定された定数に設定されていた値を返します。

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

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

組み込みクラス/モジュールを設定している定数...

Marshal フォーマット (72.0)

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

...ss

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

'C' で始まるデータ構造になります。

//emlist{
| 'C' | クラス名(Symbol)の dump | 親クラスのインスタンスの dump |
//}

//emlist[例 1][ruby]{
class Foo < Array # (or String, Regexp...
...//}

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

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

//emlist[例 2: インスタンス変数あり][ruby]{
class Foo < Array # (or String, Regexp...
...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:...

Module#remove_class_variable(name) -> object (12.0)

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

...引数で指定したクラス変数を取り除き、そのクラス変数に設定さ
れていた値を返します。

@param name String または Symbol を指定します。

@return 引数で指定されたクラス変数に設定されていた値を返します。

@raise NameError 引数...
...ールやクラスに定義されていない場合に発生します。

//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...