How can I get a list of all variables in a binding?

binding, ruby

Solution

You get the list of local variables in a binding by doing `eval("local_variables", the_binding)`.

I'm not sure whether that's what you meant by "Or do I always have to use this in conjunction with `local_variables`?", but there's no way to get the list without invoking `local_variables` somehow.

Problem

Does a `Binding` know the variables it stores? Or do I always have to use this in conjunction with `local_variables`?

Original source