このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.0 リファレンスマニュアル

instance method SystemExit#success?

success? -> bool[permalink][rdoc][edit]

終了ステータスが正常終了を示す値ならば true を返します。

大半のシステムでは、ステータス 0 が正常終了を表します。

begin
  exit true
rescue SystemExit => err
  p err.success?  # => true
end

begin
  exit false
rescue SystemExit => err
  p err.success?  # => false
end