At Thu, 14 Mar 2002 04:43:38 +0900,
Steven Lumos wrote:

> Is it possible to get the value of a constant given its name as a
> string or symbol without using eval?

That is Module#const_get(const). 

  Math::constants.each do |name|
    p [name, Math::const_get(name)]
  end

produces

  ["PI", 3.141592654]
  ["E", 2.718281828]


Module#const_defined?(const) checks if the const is defined there.

  module A
    X = 0
  end
  
  class C
    include A
    Y = 1
  end

  p A::const_defined?(:X)    #=> true
  p A::const_defined?(:Y)    #=> false
  p A::const_get?(:X)        #=> 0

  p C::const_defined?(:X)    #=> false
  p C::const_defined?(:Y)    #=> true
  p C::const_get?(:X)        #=> 0
  p C::const_get?(:Y)        #=> 1

-- Gotoken