local_variables -> [Symbol][permalink][rdoc]-
ローカル変数の一覧を Symbol の配列で返します。
def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] end endこのメソッドは以下のコードと同様の動作をします。
binding.eval("local_variables")
このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ
local_variables -> [Symbol][permalink][rdoc]ローカル変数の一覧を Symbol の配列で返します。
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
このメソッドは以下のコードと同様の動作をします。
binding.eval("local_variables")