tags:

views:

29

answers:

1

In Ruby, is there a way to print out all the Global variables and Constants defined / predefined?

+4  A: 

The global_variables method returns an array of all global variable names. To get the names of all the constants defined in a module, send constants to the relevant module. For example, to get all the constants that you can access without specifying a namespace, use Object.constants.

Chuck
To expand on this - you may want to check ObjectSpace module as well.
Eimantas