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.
>   
if defined? Foo::Bar
  # ...
end

-- 
Florian Frank