From: "trans (Thomas Sawyer)" <transfire@...>
Date: 2012-03-26T00:07:21+09:00
Subject: [ruby-core:43667] [ruby-trunk - Feature #4840] Allow returning from require


Issue #4840 has been updated by trans (Thomas Sawyer).


I've had occasion to use this as well, especially for RUBY_VERSION specific code.

I wonder if it is okay to be embedded in other code though. Would this work?

  class Q
    def foo
      exit_script
    end
  end

  Q.new.foo

Is it a good idea for it to work? Or should exit_script only be allowed at toplevel?

----------------------------------------
Feature #4840: Allow returning from require
https://bugs.ruby-lang.org/issues/4840#change-25169

Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 


I have a situation where there is some code in Gitorious like:

unless defined? GitoriousConfig
  # tons of lines here
end

And I would it to look like

return if defined? GitoriousConfig

#tons of lines here

It would be great to allow return from a required file or some other keyword (break, etc or a new one)


-- 
http://bugs.ruby-lang.org/