title: Learn to Program - eachEven method example - need help understanding iteration
body: <p>In Chris Pine's Learn to Program book(chapter 10) he uses the following example to explain how ruby changes a bloc into a proc.  So I understand that part although not understanding the iteration..
  following is the example/code.</p>
  
  <pre><code>class Array
    def eachEven(&amp;wasABlock_nowAProc)
  
   # We start with "true" because arrays start with 0, which is even.
  
      isEven = true
  
      self.each do |object|
        if isEven
          wasABlock_nowAProc.call object
        end
  
        isEven = (not isEven)  # Toggle from even to odd, or odd to even.
      end
    end
  end
  
  ['apple', 'bad apple', 'cherry', 'durian'].eachEven do |fruit|
    puts 'Yum!  I just love '+fruit+' pies, don\'t you?'
  end
  
  # Remember, we are getting the even-numbered elements
  # of the array, all of which happen to be odd numbers,
  # just because I like to cause problems like that.
  
  [1, 2, 3, 4, 5].eachEven do |oddBall|
    puts oddBall.to_s+' is NOT an even number!'
  end
  </code></pre>
  
  <p>Which yields,</p>
  
  <pre><code>Yum!  I just love apple pies, don't you?
  Yum!  I just love cherry pies, don't you?
  1 is NOT an even number!
  3 is NOT an even number!
  5 is NOT an even number!
  </code></pre>
  
  <p>To me it looks like the eachEven method only calls the <code>.each</code> method on the block passed in and then there after set <code>isEven</code> to <code>not isEven</code>.  Could someone please explain the flow and toggle part of the code..
  thanks guys, I truly appreciate all the help I can find.</p>