From: Stephen Sykes Date: 2011-06-05T03:37:08+09:00 Subject: [ruby-core:36734] Re: [Ruby 1.9 - Feature #4824] Provide method Kernel#executed? Some other suggestions: if main? if first_script? if main_script? if run_script? -Stephen On Sat, Jun 4, 2011 at 5:48 PM, Cezary wrote: > On Sat, Jun 04, 2011 at 11:17:01PM +0900, Yukihiro Matsumoto wrote: >> >> 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 the inverse or something similar: > > �unless required? �# top-level file, not require'd or loaded > � �#main > � �puts "hello from main" > �end > > This would also protect from main being run twice when the file > includes itself. > > > -- > Cezary Baginski > >