How to list local-variables in Ruby?

Cheng picture Cheng · Dec 20, 2010 · Viewed 10.5k times · Source
def method
  a = 3
  b = 4

  some_method_that_gives # [a, b] 
end

Answer

Nakilon picture Nakilon · Dec 20, 2010

local_variables

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