What is the reason that Kernel#require only accepts one filename?
Implementing a version of `require' that can take multiple arguments is pretty easy:
module Kernel
alias_method :__require__, :require
def require(*filenames)
filenames.all? { |file| __require__(file) }
end
end
Cheers,
Daniel
Perhaps to allow version specification in the future.
E.g.:
require 'foo', '>= 1.0.1'
like RubyGems require_gem.
Regards,
Stefan
···
On Sunday 30 October 2005 16:17, Daniel Schierbeck wrote:
What is the reason that Kernel#require only accepts one filename?
Implementing a version of `require' that can take multiple
arguments is pretty easy:
module Kernel
alias_method :__require__, :require
def require(*filenames)
filenames.all? { |file| __require__(file) }
end
end
Or you can turn the problem around:
%w[file1 file2].each { |f| require f }
···
On Oct 30, 2005, at 7:17 AM, Daniel Schierbeck wrote:
What is the reason that Kernel#require only accepts one filename?
Implementing a version of `require' that can take multiple arguments is pretty easy:
module Kernel
alias_method :__require__, :require
def require(*filenames)
filenames.all? { |file| __require__(file) }
end
end
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
Yukihiro Matsumoto wrote:
Hi,
>What is the reason that Kernel#require only accepts one filename?
Since we'd like to keep it for "parametrized require" in the future.
matz.
Good enough for me!
Cheers,
Daniel
···
In message "Re: Kernel#require accepting multiple arguments?" > on Mon, 31 Oct 2005 00:17:06 +0900, Daniel Schierbeck <daniel.schierbeck@gmail.com> writes: