title: Ruby yield example explanation?
body: <p>I'm doing a SaaS course with Ruby. On an exercise, I'm asked to calculate the cartesian product of two sequences by using iterators, blocks and yield.</p>
  
  <p>I ended up with this, by pure guess-and-error, and it seems to work. But I'm not sure about how. I seem to understand the basic blocks and yield usage, but this? Not at all.</p>
  
  <pre><code>class CartProd
    include Enumerable
    def initialize(a,b)
          @a = a
          @b = b
    end
    def each
          @a.each{|ae|
                  @b.each{|be|
                          yield [ae,be]
                  }
          }
    end
  end
  </code></pre>
  
  <p>Some explanation for a noob like me, please?</p>
  
  <p>(PS: I changed the required class name to CartProd so people doing the course can't find the response by googling it so easily)</p>