title: How to execute closure as value of a Groovy map?
body: <p>I have the following code</p>
  
  <pre><code>#!/usr/local/homebrew/bin/groovy
  
  def jobs = ['Groovy', 'Rocks', 'Big', 'Time']
  
  def generateStage(String service, Integer sleepTime=0) {
      return {
            sleep sleepTime
            println "Hello $service"
      }
  }
  
  Map generateStageMap(List list) {
      Integer sleepTime = 0
      Map stageMap = [:]
      list.each {
          stageMap[it] = generateStage(it, sleepTime)
          // slightly staggered starts so we don't have too many
          // request per sec to the CLI
          sleepTime += 5
      }
      return stageMap
  }
  
  Map map = generateStageMap(jobs)
  map.each {
    it.value
  }
  </code></pre>
  
  <p>How do I make it execute the println statement so output looks like this?</p>
  
  <pre><code>Hello Groovy
  Hello Rocks
  Hello Big
  Hello Time
  </code></pre>
  
  <p>Or better yet, how can I check that the generated closure contains the key. For example, in pseudo-code</p>
  
  <pre><code>map.each {
    // just sample code that conveys the idea
    assert it.value.contains(it.key)
  }
  </code></pre>