1
因此,我剛剛瞭解了ARGV和參數,並且試圖將gets.to_i(或gets.chomp)結合到同一個腳本中。但它沒有發生。有什麼建議麼?我無法將gets.to_i與ARGV參數結合起來,在Ruby中
a, b, c, d, e, f = ARGV
puts "you will first go to point #{a}, then #{b}, then #{f}, finishing off with #{e} and finally #{d}."
print "Give me a number: "
time = gets.to_i
puts "you can start at #{time}"
我不斷收到以下錯誤信息:
Give me a number: ex13.rb:12:in `gets': No such file or directory @ rb_sysopen - alpha (Errno::ENOENT)
from ex13.rb:12:in `gets'
from ex13.rb:12:in `<main>'
輸出我得到的,在不添加gets.to_i是: 「你先去點α,然後喝彩,然後是狐步舞,用回聲完成,最後是三角洲。「
腳本不產生任何錯誤 –
見http://stackoverflow.com/q/2166862 – cremno
看起來不像同樣的問題:如果你重寫它這樣你的代碼工作。如果是這樣,它不能幫助我解決問題。令人懷疑的是,我可以解釋我的問題與假設的重複問題有何不同。 – Padawan