From: Gavin Sinclair Date: 2003-09-11T07:47:32+09:00 Subject: Re: What *are* variables? Which are nil now? On Thursday, September 11, 2003, 4:00:10 AM, Hugh wrote: > Reading about reflection, ObjectSpace will give you the objects in > your system, possibly selected by Class. Fine. It won't tell you > which variables are associated with them. You can trace on global > variables, you can look at instance variables, but how can you get > information about all variables? What *is* a variable, exactly, come > to that? It works like a sticky label so you can have two on the > same object, but are the variables themselve objects in ruby? Can I > twist ObjectSpace's arm to tell me about them? Variables are not objects; it's as simple as that. They are sticky notes. You can get a list of local variables in any scope with Kernel::local_variables. Then you can eval them to find out what they are. You can get a list of variables in other scopes as well. I have a marvellous proof for this, which this margin is too small to contain. Gavin