title: Unexpected Return (LocalJumpError)
body: <p>What is the problem with this Ruby 2.0 code?</p>
  
  <pre><code>p (1..8).collect{|denom|
      (1...denom).collect{|num|
          r = Rational(num, denom)
          if r &gt; Rational(1, 3) and r &lt; Rational(1, 2)
              return 1
          else
              return 0
          end
      }
  }.flatten
  </code></pre>
  
  <p>The error is     in <code>block (2 levels) in &lt;main&gt;': unexpected return (LocalJumpError)</code>. I want to create a flat list containing <em>n</em> ones (and the rest zeroes) where <em>n</em> is the number of rational numbers with denominators below 8 which are between 1/3 and 1/2. (<a href="http://projecteuler.net/problem=73" rel="noreferrer">it's a Project Euler problem</a>). So I'm trying to return from the inner block.</p>