Maybe use a hash instead? It may be a little bit of a pain to add all the objects one at a time depending on how many you have, but the payoff is it will give you what (I think) you want and maybe more....in case you are not familiar with hashes (you said you're new) here is how you do it:
create hash, I will call my hash 'variables'
variables = {}
add items to hash use: hash_name['key_name'] = 'value'.
variables['var1'] = 'something1' variables['var2'] = 'something2' variables['var3'] = 'something3'
If you have a variable that looks like this:
foo = 'foobar' #then 'foo' would be the key_name and 'foobar' would be the value.
Once you hash is created, to see entire hash, both keys and values:
puts variables #=> {"var1"=>"something1", "var2"=>"something2", "var3"=>"something3"}
look at keys only:
puts variables.keys # => var1 # => var2 # => var3
to look at values only:
puts variables.values # => something1 # => something2 # => something3
to see what is in one particular key:
puts variables['var3'] # => something3
If you for some reason NEEDED an array with only your key(object) names you could you could easily do that by creating an array and pushing all the keys into it at once like this:
all_vars_array = [] all_vars_array << variables.keys #pushes ALL the keys of your hash into your array. puts all_vars_array # => ['var1', 'var2', 'var3']
So you see, building a hash may be worth the effort depending on what your doing.
a = A.new; b = a? Someone wanting to do this sort of thing often indicates some confusion between objects and variables or that they're trying to do something strange.