Cheng Cheng - 7 months ago 74
Ruby Question

How to list local-variables in Ruby?

def method
a = 3
b = 4

some_method_that_gives # [a, b]
end

Answer

local_variables

It outputs array of symbols, presenting variables. In your case: [:a, :b]