Im trying to create an array containing the
difference of the two other arrays. When I create the
arrays manual I have no problems.
a = ["0001", "0002"]
b = ["0001", "0002", "0003"]
c = b - a
puts c
c -> 0003
However when the array is created from data in a file
d will equal the first array not the difference
between the two.
File.open("datafilelist.txt").each { |h| data_files1
<< h}
d = data_files1 - data_files
puts d
-> 0001, 0002
Thoughts?
Jeff Bowen
···
____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
I guess the trailing newline in the elements of data_files1 is the culprit. In that case push h.chomp instead of h. In any case, inspect the arrays.
-- fxn
···
On Jul 5, 2007, at 9:20 PM, Jeffrey Bowen wrote:
I’m trying to create an array containing the
difference of the two other arrays. When I create the
arrays manual I have no problems.
a = ["0001", "0002"]
b = ["0001", "0002", "0003"]
c = b - a
puts c
c -> 0003
However when the array is created from data in a file
d will equal the first array not the difference
between the two.
File.open("datafilelist.txt").each { |h| data_files1
<< h}
d = data_files1 - data_files
puts d
-> 0001, 0002
You haven't shown enough code to get any help! What is data_files? Giving us a sample of the contents of "datafilelist.txt" would be quite useful, too.
-Rob
Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
k
···
On Jul 5, 2007, at 3:20 PM, Jeffrey Bowen wrote:
I’m trying to create an array containing the
difference of the two other arrays. When I create the
arrays manual I have no problems.
a = ["0001", "0002"]
b = ["0001", "0002", "0003"]
c = b - a
puts c
c -> 0003
However when the array is created from data in a file
d will equal the first array not the difference
between the two.
File.open("datafilelist.txt").each { |h| data_files1
<< h}
d = data_files1 - data_files
puts d
-> 0001, 0002
Thoughts?
Jeff Bowen
Thanks. inspect showed the problem.
···
--- Xavier Noria <fxn@hashref.com> wrote:
On Jul 5, 2007, at 9:20 PM, Jeffrey Bowen wrote:
> Im trying to create an array containing the
> difference of the two other arrays. When I create
the
> arrays manual I have no problems.
>
> a = ["0001", "0002"]
> b = ["0001", "0002", "0003"]
> c = b - a
> puts c
> c -> 0003
>
> However when the array is created from data in a
file
> d will equal the first array not the difference
> between the two.
>
> File.open("datafilelist.txt").each { |h|
data_files1
> << h}
>
> d = data_files1 - data_files
> puts d
> -> 0001, 0002
I guess the trailing newline in the elements of
data_files1 is the
culprit. In that case push h.chomp instead of h. In
any case, inspect
the arrays.
-- fxn
____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222