J
James Byrne
I am loading file names and mtimes into an array and then putting that
array inside an outer array. I have run into the situation where the
same file sometimes exists in different places in the file system and
occasionally with a different file name.
I need to ensure that I process the contents of each file only once.
So, in addition to the two elements originally captured I now create an
MD5 hexdigest of the file contents: [ f.mtime, f.name, f.hexdigest ]
and store that.
Now I wish to ensure that each distinct hexdigest is processed but once.
I can do this:
hex_array = []
outer_array.each do |inner_array|
next if hex_array.include?( inner_array[2] )
hex_array << inner_array[2]
. . .
I wonder if there is a better way? Any suggestions?
array inside an outer array. I have run into the situation where the
same file sometimes exists in different places in the file system and
occasionally with a different file name.
I need to ensure that I process the contents of each file only once.
So, in addition to the two elements originally captured I now create an
MD5 hexdigest of the file contents: [ f.mtime, f.name, f.hexdigest ]
and store that.
Now I wish to ensure that each distinct hexdigest is processed but once.
I can do this:
hex_array = []
outer_array.each do |inner_array|
next if hex_array.include?( inner_array[2] )
hex_array << inner_array[2]
. . .
I wonder if there is a better way? Any suggestions?