tags:

views:

22

answers:

1

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

+1  A: 

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.

sepp2k
I was thinking the binding had a method which would list all the values it contained ( so that I wouldn't have to pass along the array returned by `local_variables` )
Geo
Well, you don't have to pass it along because you can get it at any time using eval. There is no method though, unless you define one `class Binding; def variables() self.eval("local_variables") end end`
sepp2k