title: pass optional block to an inline lambda
body: <p>I have created a lambda called <code>imap_query</code> below that wraps a call to a method call that I need to make twice in the code below.</p>
  
  <p>The first time I call the <code>imap_query</code> lambda, I do not want to pass a block in as I only want the return value of the <code>google.email.find</code> function call.  </p>
  
  <p>The second time I call the <code>imap_query</code> lambda, I want to pass a block.</p>
  
  <pre><code>  def process_emails(user, google, folder)
      since_time = Net::IMAP.format_date 1.day.ago
  
      imap_query = -&gt; {
                        google.email.find(mailbox: folder, read_only: true, count: max_emails, keys: [ 'RECENT', 'SINCE', since_time ])
                       }
  
      @email_total = imap_query().size
  
      return finish_sync(user) if @email_total == 0
  
      # how do I pass a block to the imap_query lambda
      imap_query.call() do |mail, imap, uid|
        update_progress user
        yield mail, imap, uid
      end
    end
  </code></pre>
  
  <p>What I am struggling with is:</p>
  
  <ol>
  <li>How to declare the lambda with an optional block parameter.</li>
  <li>How to call the lambda and pass a block in, if I want to pass one in.</li>
  </ol>