But, I have to be honest it seems a bit strange to not have to use
exception handling. Especially, when coming from the Java way of doing
things.
You still need to handle the exception somewhere unless you want to let
it terminate the program. It’s just the file handle closing that is
ensured to be done under all circumstances. And btw you can do the
similar things in Java with a finally block - it’s just awfully more
verbose. And even Java has unchecked exceptions (everything that
inherits Error and RuntimeException).
But, I have to be honest it seems a bit strange to not have to use
exception handling. Especially, when coming from the Java way of doing
things.
You still need to handle the exception somewhere unless you want to let
it terminate the program. It’s just the file handle closing that is
ensured to be done under all circumstances. And btw you can do the
similar things in Java with a finally block - it’s just awfully more
verbose. And even Java has unchecked exceptions (everything that
inherits Error and RuntimeException).
Alright, but I guess what I am missing is HOW do we handle the
excpetion? I see now recuse statement.
Maybe I am missing something obvious but, with Java the method signature
indicated the exception being thrown. That way in the calling method I
could deal with it. In this example while I understand that the file
handle will be closed how do you handle an exception raised?
Alright, but I guess what I am missing is HOW do we handle the
excpetion? I see now recuse statement.
You have to write it yourself.
Maybe I am missing something obvious but, with Java the method signature
indicated the exception being thrown.
As I said, this is not 100% true. There are unchecked exceptions in
Java as well. Practically in Ruby the documentation should state
which exceptions can be thrown.
That way in the calling method I
could deal with it. In this example while I understand that the file
handle will be closed how do you handle an exception raised?