From: Benoit Daloze Date: 2010-05-26T22:03:14+09:00 Subject: [ruby-core:30441] Re: [Feature #3346] __DIR__ revisted Hi, On 26 May 2010 14:17, U.Nakamura wrote: > Hello, > > In message "[ruby-core:30436] [Feature #3346] __DIR__ revisted" > � �on May.26,2010 20:59:48, wrote: >> I like __DIR__. > > I like Kernel#__dir__. > > > Regards, > -- > U.Nakamura > I prefer __DIR__. ( as a keyword, because it's clearly the same family with __FILE__, and it's a constant (so in uppercase) ) My first use would be things like Dir[File.join(__DIR__,'*.rb')].each { |f| require f } That's only because I am sometimes too lazy to "require_relative" all the files under the same dir. But maybe that's not the best way to do it, tough. Currently, there is also another possibility, which is kind of a hack: Dir[File.expand_path("../*.rb",__FILE__)].each { |f| require f } Just some ideas in the air for this case: - require_relatives - require_relative '*.rb' - require_relative '*' (then assume we want only .rb files) - require_relative (then the meaning would be "require the relative stuff, what is relative to this") The 2nd and 3rd one obviously more flexible as they accept a glob matching pattern. Anyway, there are still many cases in which __DIR__ would be useful, even if that's kind of low-level stuff. Regards, B.D.