File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ruby and the fly likes What is catch/throw ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "What is catch/throw ?" Watch "What is catch/throw ?" New topic

What is catch/throw ?

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

In Ruby, begin/rescue/ensure are the equivalents for Java's try/catch/finally.
Ruby has catch/throw constructs, what are these?
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 430
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

For all practical purposes, you'll probably never catch or throw. begin/rescue/end is primarily used and it's idiomatic in Ruby to simply return null or other default value from a method in *some cases* where Java would choose to throw an exception.

A good workman is known by his tools.
I agree. Here's the link:
subject: What is catch/throw ?
It's not a secret anymore!