我有代碼:紅寶石意想不到的關鍵字結束
results = ["http://www.google.com", "http://www.yahoo.com.uk"]
results.each do |results|
File.open("#{results}.html", "w") do |file|
file.write(RestClient.get(#{result}))
end
end
當我運行程序時,它給了我一個錯誤:
syntax error, unexpected keyword_end, expecting ')'
我有兩個do
-s和兩個end
-s。請幫忙。
如果將它放在一行中,那會怎麼樣:'File.open(「#{results} .html」,「w」){| file | file.write(RestClient.get(#{result}))}'?它會拋出一個錯誤嗎? –
請發佈完整的錯誤消息和相應的行號。此外,似乎應該檢查何時使用「結果」和何時使用「結果」。 – spickermann
是的!此外,我還有另一個「做」。嘗試使用兩個{},仍然是一個錯誤。 –