Exception Handling • Exercise 2/4

Multiple Rescue

00:00
0
20 points

Instructions

Create a function parse_number that takes a string and returns
a parsed integer. Handle these cases:

  • Valid number string: return the integer
  • Invalid format: return :invalid_format
  • Nil input: return :no_input

Rescue multiple exception types:
ruby
begin
# code
rescue ArgumentError
# handle one type
rescue NoMethodError
# handle another
end

Your Code

Results

Click "Run Tests" to see results