J
James Byrne
I create an array of arrays, each inner array containing the mtime value
and fully qualified pathname of a file.
sources = [ [ mtime.to_i, "filename" ], [. . . ] ]
It happens that the same file is occasionally added twice or more. I
want to eliminate the duplicates. I thought that sources.uniq! would
work but I was surprised to discover that it returned nil indicating
that there were no duplicates found. I then tried sources.uniq.sort to
see if this was true and saw this:
1276181402
acrfile.0610104802
1276181402
acrfile.0610104802
1276181402
acrfile.0610104802
All elements of the outer array belong to class Array. The class of the
first element in each inner array is Fixnum, that of the second is
String.
So, what is it about Array#uniq that I misapprehend? Why do three
apparently identical inner arrays remain in the outer array after #uniq
is applied to it?
and fully qualified pathname of a file.
sources = [ [ mtime.to_i, "filename" ], [. . . ] ]
It happens that the same file is occasionally added twice or more. I
want to eliminate the duplicates. I thought that sources.uniq! would
work but I was surprised to discover that it returned nil indicating
that there were no duplicates found. I then tried sources.uniq.sort to
see if this was true and saw this:
1276181402
acrfile.0610104802
1276181402
acrfile.0610104802
1276181402
acrfile.0610104802
All elements of the outer array belong to class Array. The class of the
first element in each inner array is Fixnum, that of the second is
String.
So, what is it about Array#uniq that I misapprehend? Why do three
apparently identical inner arrays remain in the outer array after #uniq
is applied to it?