我的Ruby编程代码有什么问题?

我的Ruby编程代码有什么问题?,ruby,syntax,syntax-error,Ruby,Syntax,Syntax Error,这个代码应该是有效的。但每次我在Ruby上打开它时,Ruby几乎立即关闭,因为它无法读取代码中的某些内容。很明显,代码中有个错误,但我检查了所有内容,似乎都找不到。我需要一些帮助来让代码正常工作。提前非常感谢 puts 'Enter the number of the current month using the 12 months per year scale. Ex. January would be 1, February would be 2, March would be 3, et

这个代码应该是有效的。但每次我在Ruby上打开它时,Ruby几乎立即关闭,因为它无法读取代码中的某些内容。很明显,代码中有个错误,但我检查了所有内容,似乎都找不到。我需要一些帮助来让代码正常工作。提前非常感谢

puts 'Enter the number of the current month using the 12 months per year scale. Ex. January would be 1, February would be 2, March would be 3, etc...'
month=gets.chomp
case month
when '1'..'3'
fee='$45'
when'4'..'5'
fee='$55'
when'7'..'8'
fee='$65'
else
fee='$0.00'
end
puts'The fee to apply for the competition is ' + fee + '.00 when you apply on the date of today, ' + Time.now.to_s +'.'
puts 'If your fee came up as $0.00, then that is because the competition has ended. But do not worry, there is always next year!'
sleep 20

Ruby告诉我语法错误是:

temp.rb:13:语法错误,意外的元组,应为$end
... 从今天开始,“+Time.now.to_+”
+
'之间添加空格。
修复了语法错误


您可以通过从命令行运行Ruby来解决这个问题。我想你正在运行Windows。要进入命令提示符,可以按Windows键和R键打开“运行”对话框。在那里,您可以键入
cmd
,然后按enter键打开命令提示符。然后可以使用
cd
更改当前目录,并使用
ruby
运行ruby脚本(假设ruby位于
路径中)。您的会话可能如下所示:

C:\Documents and Settings\Madelyn Grewal>cd桌面
C:\Documents and Settings\Madelyn Grewal\Desktop>ruby myscript.rb
rb:13:语法错误,意外的元组,应为$end
... 从今天开始,“+Time.now.to_+”
C:\Documents and Settings\Madelyn Grewal\Desktop>

Ruby告诉我语法错误是:

temp.rb:13:语法错误,意外的元组,应为$end
... 从今天开始,“+Time.now.to_+”
+
'之间添加空格。
修复了语法错误


您可以通过从命令行运行Ruby来解决这个问题。我想你正在运行Windows。要进入命令提示符,可以按Windows键和R键打开“运行”对话框。在那里,您可以键入
cmd
,然后按enter键打开命令提示符。然后可以使用
cd
更改当前目录,并使用
ruby
运行ruby脚本(假设ruby位于
路径中)。您的会话可能如下所示:

C:\Documents and Settings\Madelyn Grewal>cd桌面
C:\Documents and Settings\Madelyn Grewal\Desktop>ruby myscript.rb
rb:13:语法错误,意外的元组,应为$end
... 从今天开始,“+Time.now.to_+”
C:\Documents and Settings\Madelyn Grewal\Desktop>

在命令行上运行它,它不会“立即关闭”。这样您就可以看到错误消息。在命令行上运行它,它不会“立即关闭”。这样您就可以看到错误消息。