るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
2件ヒット [1-2件を表示] (0.150秒)

別のキーワード

  1. _builtin eval
  2. module module_eval
  3. kernel eval
  4. module class_eval
  5. _builtin class_eval

ライブラリ

クラス

検索結果

Binding#local_variables -> [Symbol] (72661.0)

ローカル変数の一覧を Symbol の配列で返します。

ローカル変数の一覧を Symbol の配列で返します。

//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}

このメソッドは以下のコードと同様の動作をします。

//emlist[][ruby]{
binding.eval("local_variables")
//}

Object#instance_variables -> [Symbol] (18340.0)

オブジェクトのインスタンス変数名をシンボルの配列として返します。

オブジェクトのインスタンス変数名をシンボルの配列として返します。

//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables

#=> [:@foo, :@bar]
//}

@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variabl...