title: Pass method as parameter Groovy
body: <p>I am creating a Groovy project and I would like to pass a method as a parameter is this possible?</p>
  
  <p>I have 2 methods, which basically do the same thing but have a few small differences, each have different properties.</p>
  
  <p>I would like to send through whether to use the 'buildPayLoad' function or 
  'buildSecondPayLoad' into my sendEmail function. </p>
  
  <pre><code>    private Operation sendEmail(Order order) {
                    def payload = buildPayload(order, templateId)
      }
  
  
      private firstEmailPayLoad buildPayload(Order order, String templateId) {
              new firstEmailPayLoad(
                  templateId,
                  config.fromAddress,
                  order.firstPayLoadProperty,
                  buildEmailDataFirstPayLoad(order)
              ).validate()
     }
  
     private secondEmailPayLoad buildSecondPayLoad(Order order, String templateId) {
              new secondEmailPayLoad(
                  templateId,
                  config.fromAddress,
                  config.bccAddress,
                  config.otherProperty,
                  order.secondPayLoadProperty
                  buildEmailData(order)
              ).validate()
   }
  </code></pre>