REMOVE_WORDS_ARRAY = ["llc", "co", "corp", "inc", "the"]
businesses_array = import_csv.import('businesses.csv')
print businesses_array
# [["the bakery", "10012"]["law office inc", "10014"]]
businesses_hashes = []
our_hash = {}
businesses_array.each do |business|
our_hash['BusinessName'] = business[0].strip unless business[0].nil?
our_hash['BusinessZipCode'] = business[1].strip unless business[1].nil?
our_hash.each {|key, value|
our_hash[key] = value.downcase!
our_hash[key] = (value.split(' ') - REMOVE_WORDS_ARRAY) # only this part doesn't get updated. why?
our_hash[key] = value.gsub(' ', '+')
}
businesses_hashes << our_hash
our_hash = {}
end
当我打印时,our_hash
我可以看到名称已被小写并+
已添加,但单词尚未删除。我错过了什么?