exit
は例外処理を記述すれば処理を続行出来る。 exit!
は例外処理を一切行わずプログラムを終了する。
def proc_exit
puts "proc_exit"
exit
rescue SystemExit
puts "rescued a SystemExit exception"
end
def proc_exit!
puts "proc_exit!"
exit!
rescue SystemExit
puts "rescued a SystemExit exception"
end
proc_exit
proc_exit!
出力
proc_exit
rescued a SystemExit exception
proc_exit!
参考サイト