C
Chas Conquest
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)
File.rename(letters, ordinals)
puts "switched to ordinal"
else
File.rename(ordinals, letters)
puts "switch to letter"
end
end
end
end
switcher = FileNameSwap.new
switcher.switch(ar,br, length)
<---end---->
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)
File.rename(letters, ordinals)
puts "switched to ordinal"
else
File.rename(ordinals, letters)
puts "switch to letter"
end
end
end
end
switcher = FileNameSwap.new
switcher.switch(ar,br, length)
<---end---->