概要
Kernel#local_variables -> [Symbol]
詳細
現在のスコープにあるローカル変数名の一覧を配列にして返します。
サンプルコード
require 'pp' require 'test_toolbox' def hoge(args_a, args_b) c = 'hoge c' d = 'hoge d' pp local_variables end a = 'a' b = 'b' pp local_variables dp_line __LINE__ hoge(:args_a, :args_b)
出力
[:a, :b] --------------------|filename=|line=14|-------------------- [:args_a, :args_b, :c, :d]