Return from included file

Is there a way to return from a required file? It seems the return statement is only allowed inside methods/lambdas.


You can always wrap a large portion of your code in a conditional. Since Ruby allows these nearly anywhere you can even conditionally declare classes:

if (defined?(Something))
  class SomeClass
    # ...
  end
end

This is not unlike C with #ifdef but doesn't require a separate language. It's the standard way of doing things even if you think it seems odd.