目前我正在这样做:
badLinks = Array.new
badLinksFile = File.new(arrayFilePath + 'badLinks.txt', 'w+')
badLinksFile.puts badLinks.to_json
该数组badLinks
包含哈希并且是:
brokenLink = Hash.new
brokenLink[:onPage] = @lastPage
brokenLink[:link] = @nextPage
badLinks.push(brokenLink)
当我查看文件时,它是空的。这应该工作吗?