I have directory of data files along with a few other types of files. The
data file names start at 0000 and run to 3999. I have a program that
creates an array for the data files without the non data files. This
program works good but have I created the shortest way of doing the task?
Thanks for grading my test. Jeff
#Puts the contents of the current directory into data_files.
dir_file_list = Dir.entries(".")
data_files = []
dir_file_list.each do|files|
if files.to_i > 0 && files.to_i < 4000
data_files.push files
end
end
I have directory of data files along with a few other types of files. The
data file names start at 0000 and run to 3999. I have a program that
creates an array for the data files without the non data files. This
program works good but have I created the shortest way of doing the task?
Thanks for grading my test. Jeff
#Puts the contents of the current directory into data_files.
dir_file_list = Dir.entries(".")
data_files = []
dir_file_list.each do|files|
if files.to_i > 0 && files.to_i < 4000
data_files.push files
end
end
I have directory of data files along with a few other types of files. The
data file names start at 0000 and run to 3999. I have a program that
creates an array for the data files without the non data files. This
program works good but have I created the shortest way of doing the task?
Thanks for grading my test. Jeff
#Puts the contents of the current directory into data_files.
dir_file_list = Dir.entries(".")
data_files = []
>
dir_file_list.each do|files|
if files.to_i > 0 && files.to_i < 4000
data_files.push files
end
end
puts data_files
--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw