Trans
10/9/2006 4:21:00 AM
Ross Bamford wrote:
> On Mon, 2006-10-09 at 06:55 +0900, Trans wrote:
> > Is there a better way to do conditional class extension?
> >
> > module Foo
> > if const_get(:Bar)
> > class Bar
> > def x; end
> > end
> > end recue nil
> > end
> >
> > The 'if const_get ... rescue nil' doesn't seem very elegant.
>
> Just a small change, but why not just ask if const_defined? ?
Oh yea! :-)
Thanks,
T.