概要 Rubyの例外について説明します。 構文 Rubyの例外は以下の構文で利用出来ます。 begin 例外の例外の起こる可能性のある処理 rescue 例外が起こった場合の処理 ensure 例外の有無に関わらず実行される処理 end サンプル def divide_number(number,divide) begin # Javaのtryと同様 puts "input (#{number},#{divide})" number/divide rescue => exception # Javaのcatchと同様 puts exception.message puts "like Java's catch" raise 'my error' # Javaのthrowと同様 ensure # => Javaのfinallyと同様 puts "like Java's finally" en

