From: Yukihiro Matsumoto Date: 2011-06-04T23:17:01+09:00 Subject: [ruby-core:36732] [Ruby 1.9 - Feature #4824] Provide method Kernel#executed? Issue #4824 has been updated by Yukihiro Matsumoto. I agree providing a method to tell whether it is loaded as a library or is executed as a command is more elegant than '__FILE__ == $0', but I am still afraid #executed? can mean multiple ways so that the name can cause confusion. We need a better name. ---------------------------------------- Feature #4824: Provide method Kernel#executed? http://redmine.ruby-lang.org/issues/4824 Author: Lazaridis Ilias Status: Open Priority: Normal Assignee: Category: core Target version: The current construct to execute main code looks not very elegant: if __FILE__ == $0 my_main() # call any method or execute any code end With a Kernel#executed? method, this would become more elegant: if executed? #do this #do that my_main() end or main() if executed? This addition would not break any existent behaviour. -- http://redmine.ruby-lang.org