如何告诉 Ruby 程序自行关闭

How to tell a Ruby program to close itself

是否有 ruby 命令告诉 ruby 脚本自行关闭?我想做的是:假设我是 运行 ruby.rb

print "What would you like to do next?"
next=gets.chomp   
next.downcase!
if next=="close"
    #this is where i want to be able to tell the program to close itself.
end

有没有办法做到这一点,如果有,是什么?

只需使用

exit

更多信息:

http://www.sitepoint.com/exit-exit-abort-raise-get-me-outta-here/