title: Ruby: How to create a block and pass it as an argument?
body: <p>I'm working with a method that takes a block as an argument. I'm new to Ruby and Blocks, so I don't quite understand how I would go about creating a Block and passing it to the method. Can you please provide me an example of how you would create a block and pass it as an argument?</p>
  
  <p><strong>Update:</strong> Here is an example of the method that I am trying to call:</p>
  
  <pre><code>def exec!(commands, options=nil, &amp;block)
    # method code here
    # eventually it will execute the block if one was passed
  end
  </code></pre>
  
  <p>Here is how I am currently calling this method:</p>
  
  <pre><code>@result = ssh.exec!("cd /some/dir; ls")
  </code></pre>
  
  <p>How do I pass a block as the third argument to the <code>exec!</code> method?</p>