From: Gregory Brown Date: 2011-06-16T06:24:50+09:00 Subject: [ruby-core:37156] Re: [Ruby 1.9 - Feature #4824] Provide method Kernel#executed? On Sat, Jun 4, 2011 at 10:17 AM, Yukihiro Matsumoto wrote: > > 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. How about main_program? if main_program? puts "Executing main program!" end or possibly executed_directly? if executed_directly? puts "This was executed directly by Ruby" end someone else suggested directly_executed? which I think is also fine. Lastly, I think __MAIN__ is reasonable if a method is not to be used, though it feels a bit too magic for me.