Hi,

Could you please point out how I can make this code more
compact/cleaner/smarter???
Gotta be a block..I just don't see how to connect it.

Gratefully,

Chas

<------Switch File Names--->

ar = ["a.txt", "b.txt", "c.txt", "d.txt", "e.txt"]
br = ["first.txt", "second.txt", "third.txt", "fourth.txt", "fifth.txt"]

length = ar.length
class FileNameSwap
  def switch( letters, ordinals, length)
 for i in 0..length -1
    if File.file?(letters[i])
      File.rename(letters[i], ordinals[i])
      puts "switched to ordinal"
    else
      File.rename(ordinals[i], letters[i])
      puts "switch to letter"
    end
      end
  end
end

switcher = FileNameSwap.new
switcher.switch(ar,br, length)

<---end---->

-- 
Posted via http://www.ruby-forum.com/.