Pattern Match On Exceptions
Last updated
Was this helpful?
Last updated
Was this helpful?
supports through the switch
statement. This even includes pattern matching against exceptions that may arise as a way of catching and handling those exceptions.
The detail what happens in the two kinds of out of bounds scenarios that would raise an error -- Failure
and Invalid_argument
. You can pattern match against those by declaring the respective cases as exception instances and then returning the desired values in response.