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