I am not generally too keen on relying upon global variables, particularly when they have ‘names’ as undescriptive as $!. Fortunately, there is an alternative.
I am not generally too keen on relying upon global variables, particularly when they have ‘names’ as undescriptive as $!. Fortunately, there is an alternative.
The basic syntax of exception handling can be summarised as follows: begin # Some code which may cause an exception rescue # Code to recover from the exception end Here is an example
Code can be used to display a list of all Errno constants along with their numerical values
The example demonstrates the concept of exception When this code is run, the attempt to divide by zero causes an exception.
Often, when an exception occurs, the exception class is an instance of a specific named type such as ZeroDivisionError or NoMethodError.
In some languages, exceptions are trapped using the keyword catch and may be raised using the keyword throw.