るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

検索結果

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

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

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

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

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

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

VALUE rb_mod_remove_const(VALUE mod, VALUE name) (12200.0)

Object#remove_instance_variable(name) -> object (6106.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 フォーマット (3072.0)

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

...バージョン 4.8 を元に記述しています。

=== nil, true, false

それぞれ、'0', 'T', 'F' になります。

//emlist[][ruby]{
p Marshal.dump(nil).unpack1("x2 a*") # => "0"
p Marshal.dump(true).unpack1("x2 a*") # => "T"
p Marshal.dump(false).unpack1("x2 a*") # => "F"
//}

Ruby 2....
...==== 形式 1

数値 n に対して

//emlist{
n == 0: 0
0 < n < 123: n + 5
-124 < n < 0: n - 5
//}

という数値(1 byte)を格納します。5 を足したり引いたりするのは下記の
形式 2 との区別のためです。

//emlist[例][ruby]{
p Marshal.dump(-1).unpack1("x2 a*...
...ist[例 2: クラス/モジュールのインスタンス変数は dump されない][ruby]{
module Bar
@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,...

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

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

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

絞り込み条件を変える