From: George Ogata Date: 2004-08-12T07:51:13+09:00 Subject: Re: Is this potentially a problem? "DaZoner" writes: > I've defined a class I use that strips methods off of a class (specified by > a string representing the class name). I use it maybe 30 times during my > application run. However I'm concerned because it does an > ObjectSpace.each(Class) call to make sure the specified class exists before > trying to remove any methods. Will this call get slow as a few arrays > containing perhaps a million FixNums get defined by the application in > between calls? The array's data stays around as the calls to my class are > made. I've included the source of the class below. If anyone knows an > efficient way to determine if a class exists given its name in String form > I'd sure appreciate seeing it. > Something like: Object.const_defined?(name) && Object.const_get(name).is_a?(Class) You'd need to tweak it a bit to support nested class names like C::D::E (in that case you'd need to call C::D.const_defined?('E'), e.g.).