Is there a ruby command to tell the ruby script to close itself? What I am trying to do is this: say I'm running 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
Is there a way to do this, and if there is, what is it?
exit
? – chrisaycock May 19 '15 at 23:44exit
. Rather, it is to structure your code so that you terminate normally. For example:def my_method; loop do; next = gets.chomp; return nil if next == "close"; <do something>; end
. The calling method receivesnil
and takes appropriate action, etc. – Cary Swoveland May 20 '15 at 0:26