Get all local variables or available methods from irb?

George Mauer picture George Mauer · Apr 25, 2011 · Viewed 27.6k times · Source

When I go into irb and type in a command that does not exist I get an error stating

"undefined local variable or method 'my_method' for main:Object (NameError)"

Is there a way to just get a list of what local variables or methods ARE available? This would be really useful for exploring ruby.

Answer

Zabba picture Zabba · Apr 25, 2011

Look for methods in the Kernel, Object and Module : e.g. local_variables, instance_methods, instance_variables.

Other great methods in there. inspect is another one.