title: Why is the parameter of this method a lambda and how does it work
body: <p>Taken from Programming ruby 1.9 book:</p>
  
  <pre><code>def my_while(cond, &amp;body)
   while cond.call
     body.call
   end
  end
  
  a=0
  
  my_while -&gt; { a &lt; 3 } do
    puts a
    a += 1
  end
  </code></pre>
  
  <p>produces:</p>
  
  <p>0</p>
  
  <p>1</p>
  
  <p>2</p>