我完全被这个难倒了.我正在尝试调试一些代码,这些代码创建一个FirstRun文件作为程序已经完成其首次运行设置的标记.它尝试在指定的工作目录中创建它,由absworkingdir变量给出.但是,当它尝试创建文件时,File.new我得到以下错误
`initialize': No such file or directory '
这是相关的代码:
#First run setup
puts workingdir#debug
absworkingdir = File.expand_path(workingdir)
puts absworkingdir#debug
if File.exist?("#{absworkingdir}/FirstRun.lock") == false
puts "This appears to be the first run of FigShare Sync. We'll setup a few things."
print "Where would you like to store settings and files? [~./figsharesync]: "
@input = gets.chomp
puts @input#debug
if @input.empty? == false
workingdir = @input
absworkingdir = File.expand_path(workingdir)
end
print "Please enter OAuth consumer key: " …Run Code Online (Sandbox Code Playgroud) 我知道其他地方已经触及了这些问题,但我对if elseruby中多行(块?)语句的正确语法略感不安.
举个例子:
if condition then
do something
do somethingelse
do yetanotherthing
done
else
do acompletelyunrelatedthing
done
Run Code Online (Sandbox Code Playgroud)
我知道then如果使用多行,则需要声明,但是done在else必要之前是否需要?这似乎会脱离if...else上下文.当我这样做时,done我得到:
syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
当我不包括它时,我得到:
syntax error, unexpected keyword_else, expecting keyword_end