0
我以前從未使用過Ruby,並且試圖在2006年編寫程序。我已經安裝了Ruby和gem包,但是當我嘗試運行它,我得到一個錯誤:Ruby - 「正式參數不能是類變量」
xmltv2html.rb:231: formal argument cannot be a class variable
xmltv2html.rb:231: syntax error, unexpected '[', expecting '|'
面積給我的麻煩,特別是
def parse_command_line_options
ARGV.options do
|opts|
opts.banner = "Usage: #{File.basename($0)} <xmltv.xml> tv.html\n"
# separater
opts.on_tail
opts.on_tail("common options:")
opts.on("--configfile=FILE", String, "config file to use") {
|@@options[:config_file]|}
#more code after
我試圖使用該項目是「xmltv2html」。
有什麼特別的我做錯了嗎?我嘗試將'| @@選項'更改爲'| @options'和'| $ options',但只是更改錯誤消息以反映相關範圍。
這只是一個使用太舊項目的案例嗎?
預先感謝塊參數
的可能的複製(http://stackoverflow.com/questions/23092993/ rails-formal-argument-can-be-an-instance-variable) –
在'| @@ options [:config_file] |'上檢查你的代碼 - 這是塊的無效參數 –
@ Slava.K對於新手?記住這不是我的代碼,我從來沒有使用Ruby,我試圖讓我的頭腦圍繞這一切! – twgh