How do I check If a Class already exists in Ruby

Posted by Jimmy on Stack Overflow See other posts from Stack Overflow or by Jimmy
Published on 2009-07-27T08:38:32Z Indexed on 2010/05/29 1:22 UTC
Read the original article Hit count: 244

Filed under:
|

How do I check If a Class already exists in Ruby,

My code is:

puts "enter the name of the Class to see if it exists"   
nameofclass=gets.chomp  
eval (" #{nameofclass}......  Not sure what to write here")

I was thinking of using:

eval "#{nameofclass}ancestors.     ....."

© Stack Overflow or respective owner

Related posts about ruby

Related posts about class