From: Benoit Daloze Date: 2011-06-05T22:29:10+09:00 Subject: [ruby-core:36758] [Ruby 1.9 - Feature #4824] Provide method Kernel#executed? Issue #4824 has been updated by Benoit Daloze. Clifford Heath wrote: > That is, the problem is that it's not obvious to a newcomer that __FILE__ means > the current source-code file, or that $0 means the name of the script > being executed. Especially the latter... $PROGRAM_NAME is an alias for $0. But "if __FILE__ == $PROGRAM_NAME" is quite long. ---------------------------------------- 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