The verbose way of exception handling looks like:
def slice_it string="Ruby"
begin
string.slice
rescue ArgumentError => e
$stderr.puts "Read the API documention of String#slice. Message: '#{e}'"
end
end
but it can be less verbose without the explicit begin / end block style, because method definitions are implicitly also exception blocks:
def slice_it string="Ruby"
string.slice
rescue ArgumentError => e
$stderr.puts "Read the API documention of String#slice. Message: '#{e}'"
end