From: Phillip Gawlowski Date: 2011-07-14T06:06:36+09:00 Subject: Re: Creating a range of directories On Wed, Jul 13, 2011 at 10:55 PM, Simon Harrison wrote: > The following works, but seems to smell a bit. > > *************************** > > require 'fileutils' > include FileUtils > > var = 1..100 > dirs = var.map { |n| "%03d" % n } > dirs.each { |n| n.insert(0, "Prefix-") } > > mkdir(dirs) > > **************************** > > Any better ways to accomplish this? require 'fileutils' (1..100).each do |num| FileUtils.mkdir("prefix-%03d", num) end Note: I've only proven the code correct, not tested it. -- Phillip Gawlowski twitter.com/phgaw phgaw.posterous.com A method of solution is perfect if we can forsee from the start, and even prove, that following that method we shall attain our aim.                -- Leibniz