Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li><code>raise</code>, <code>fail</code>, <code>rescue</code>, and <code>ensure</code> handle <strong>errors</strong>, also known as <strong>exceptions</strong></li> <li><code>throw</code> and <code>catch</code> are <strong>control flow</strong></li> </ul> <blockquote> <p>Unlike in other languages, Ruby’s throw and catch are not used for exceptions. Instead, they provide a way to terminate execution early when no further work is needed. (Grimm, 2011)</p> </blockquote> <p>Terminating a single level of control flow, like a <code>while</code> loop, can be done with a simple <code>return</code>. Terminating many levels of control flow, like a nested loop, can be done with <code>throw</code>.</p> <blockquote> <p>While the exception mechanism of raise and rescue is great for abandoning execution when things go wrong, it's sometimes nice to be able to jump out of some deeply nested construct during normal processing. This is where catch and throw come in handy. (Thomas and Hunt, 2001)</p> </blockquote> <h3>References</h3> <ol> <li>Grimm, Avdi. "Throw, Catch, Raise, Rescue… I’m so Confused!" RubyLearning Blog. N.p., 11 July 2011. Web. 1 Jan. 2012. <a href="http://rubylearning.com/blog/2011/07/12/throw-catch-raise-rescue--im-so-confused/" rel="noreferrer">http://rubylearning.com/blog/2011/07/12/throw-catch-raise-rescue--im-so-confused/</a>. </li> <li>Thomas, Dave, and Andrew Hunt. "Programming Ruby." : The Pragmatic Programmer's Guide. N.p., 2001. Web. 29 Sept. 2015. <a href="http://ruby-doc.com/docs/ProgrammingRuby/html/tut_exceptions.html" rel="noreferrer">http://ruby-doc.com/docs/ProgrammingRuby/html/tut_exceptions.html</a>. </li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload