J
Joseph Divelbiss
Ok, recently started "trying" to learn this wonderful language, but am
experiencing major problems with a section of code that I think "should"
work.. and my brain is so convinced that I did it correctly that I can't
see some obvious error. Ive isolated the problem to this single section
of code.. what do you all think?
#This section reads data files and saves odd lines as the key, even
lines as the value for a hash.
if Dir["/Program Files/.../data/"].last != nil
script_data_dir = "/Program Files/.../data/"
end
build_hash = Proc.new do |type|
hash.new = type_hash
file.open("#{script_data_dir}type.dat", "r") { |file|
data = file.readlines
data.delete_if { |line| line.chomp.empty? }
until data.empty?
$type_hash[data.shift.chomp] = data.shift.chomp
end
}
end
build_hash.call(test)
end
Thanks for any help in advance..
Joseph
experiencing major problems with a section of code that I think "should"
work.. and my brain is so convinced that I did it correctly that I can't
see some obvious error. Ive isolated the problem to this single section
of code.. what do you all think?
#This section reads data files and saves odd lines as the key, even
lines as the value for a hash.
if Dir["/Program Files/.../data/"].last != nil
script_data_dir = "/Program Files/.../data/"
end
build_hash = Proc.new do |type|
hash.new = type_hash
file.open("#{script_data_dir}type.dat", "r") { |file|
data = file.readlines
data.delete_if { |line| line.chomp.empty? }
until data.empty?
$type_hash[data.shift.chomp] = data.shift.chomp
end
}
end
build_hash.call(test)
end
Thanks for any help in advance..
Joseph