hash[key] = valueto add a new key-value pair. hash.update(otherhash)to add key-value pairs from another character to the hash.
If you execute hash = foo, you reassign the hash, losing the old contents.
So, for your case, you can do:
hash = {}
File.open(file_path) do |fp|
fp.each do |line|
key, value = line.chomp.split("\t")
hash[key] = value
end
end
source
share