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? ?

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk