title: Why does the break statement in ruby behave differently when using Proc.new v. the ampersand sign?
body: <p>The break statement for blocks (as per <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;ved=0CEQQFjAB&amp;url=http://shop.oreilly.com/product/9780596516178.do&amp;ei=zdkUT6-8Befm0QG2o7ivAw&amp;usg=AFQjCNGa_POPlSo3En0uSxQUq87qcffMLg&amp;sig2=4Qbmz0SvBqVqJi_Vj2kz9w" rel="noreferrer">The Ruby Programming Language</a>) is defined as follows: </p>
  
  <blockquote>
    <p>it causes the block to return to its iterator and the iterator to return to the method that invoked it.</p>
  </blockquote>
  
  <p>Therefore when the following code is run, it results in a LocalJumpError.</p>
  
  <pre><code>def test
      puts "entering test method"
      proc = Proc.new { puts "entering proc"; break }
      proc.call # LocalJumpError: iterator has already returned
      puts "exiting test method"
  end
  test
  </code></pre>
  
  <p>While the following code <strong>does not</strong> throw a LocalJumpError. What is special about the ampersand sign? Doesn't the ampersand sign implicitly use Proc.new?</p>
  
  <pre><code>def iterator(&amp;proc)
      puts "entering iterator"
      proc.call # invoke the proc
      puts "exiting iterator" # Never executed if the proc breaks
  end
  
  def test
      iterator { puts "entering proc"; break }
  end
  test
  </code></pre>
  
  <p>In other words, I read the ampersand sign as a means of in-lining the Proc.new call. At which point the behavior should be just the same as the first code snippet.</p>
  
  <pre><code>def iterator (p = Proc.new { puts "entering proc"; break})
  ...
  end
  </code></pre>
  
  <p><em><strong>Disclaimer</em></strong>: I am newb learning the language (ruby 1.9.2), and therefore will appreciate references and a detailed synopsis.</p>