def load_
.. comics = {} //宣告一個空 Ruby Hash :comics
.. File.foreach(path) do |line| //開啟一個檔案,且一段一個區間,將每line
.... name,url=line.split(':') //的文字,從‘:’分兩段,儲存於name與url
.... comics[name]=url.strip //配對 name 與 url 至Hash
- //strip -- This quick method removes extra spaces around the url. Just in case.
.... end
沒有留言:
張貼留言