るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
2件ヒット [1-2件を表示] (0.347秒)
トップページ > バージョン:2.6.0[x] > クエリ:_builtin[x] > クエリ:binding[x] > ライブラリ:ビルトイン[x] > クエリ:local_variables[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

検索結果

Binding#local_variables -> [Symbol] (105382.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")
//}

TracePoint#binding -> Binding (78697.0)

発生したイベントによって生成された Binding オブジェクトを返します。

発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}