
Submitted by rixxon (Thu Jul 13 01:30:08 UTC 2006)
require 'foo' require 'bar' require 'xyzzy'
or iterate an array of libraries (doesn't work too well with rdoc),
%w[foo bar xyzzy].each {|lib| require lib }
Although this works fine, it feels natural that require should be able to take multiple arguments. In Python for example, it is perfectly valid to
import foo, bar, xyzzy
require 'foo', 'bar', 'xyzzy'
which will also make this possible,
require %w[foo bar xyzzy]
I think this leads to cleaner syntax; you can load multiple libraries on a single line without resorting to iterators.
module Kernel
alias :old_require :require
def require(*libs)
libs.each {|lib| old_require lib }
end
end

| Comments | Current voting | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|


RCRchive copyright © David Alan Black, 2003-2005.
Powered by .