groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kurt Andrews <kurt.w.andr...@gmail.com>
Subject closures and iterators
Date Mon, 15 Jun 2015 04:45:44 GMT
I'm trying to figure out how to pass an extra parameter to the closure
that's being passed to each in the following code

response.data.each {
  it.children.each {
    it.children.each {
      it.children.each { // growers
        println([it.type, it.profile_id, it.name, it.created,
it.modified, "", ""].join("|"))
        it.children.each { // farms
          println([it.type, it.farm_id, it.name, it.created,
it.modified, grower.profile_id, ""].join("|"))
          it.children.each { // fields
            println([it.type, it.field_id, it.name, it.created,
it.modified, grower.profile_id, farm.farm_id].join("|"))
          }
        }
      }
    }
  }
}

I'm trying to pass the grower profile_id down to the farms and the fields
and pass the farms farm_id down to fields.   Is there a simple way to do
this?

Thanks,

Kurt

Mime
View raw message