Ruby - 命令退出错误

时间:2015-07-10 15:02:21

标签: ruby exit gets chomp

我对编程完全陌生,我无法弄清楚为什么在输入以下内容时出现错误:

puts "What is your favorite number?"
number = gets.chomp
number = number.to_i + 1
puts "I suggest " + number.to_s + " as a bigger and better number"

当我在终端中运行时,会出现以下错误:

Last login: Fri Jul 10 07:56:21 on ttys000
mba-3093:~ knalavadi$ 
/var/folders/cv/tm657j1d0kg68fbb1rqtrlgjlg_hrm/T/Cleanup\ At\ Startup/ruby2-458233138.705.rb.command ; exit;

What is your favorite number?

1 个答案:

答案 0 :(得分:1)

代码有效。你是如何运行脚本的?将它放在像number.rb这样的文件中,然后输入atexit.register(port_exit) while True: x = myPort.readline() if x == "1\r\n": scalavars.door = x scala5.ScalaPlayer.Sleep(10)

来运行它