Class defined? given symbol

any idea how to tell if a class is defined if you have just the a
symbhol of its name?

defined?(:Array)  # --> true
···


tom sawyer, aka transami
transami@transami.net

  defined?(:Array) # --> true

                  ^
                  >

the first character is a capital letter ==> this is a constant

pigeon% ruby -e 'p Object.const_defined?(:Array)'
true
pigeon%

or

   Object.const_defined?(:Array) && Object.const_get(:Array).type == Class

be carefull with this

pigeon% ruby -e 'p Object.const_defined?("File::Stat")'
false
pigeon%

pigeon% ruby -e 'p File.const_defined?("Stat")'
true
pigeon%

Guy Decoux