2件ヒット
[1-2件を表示]
(0.167秒)
検索結果
-
Binding
# local _ variables -> [Symbol] (72961.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] (18640.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...