Wrote the below code which is working fine:

```
def teams = ['x', 'y', 'z']
def list = [ [id:1, team1: 'x', team2:'y' ], [id:2, team1: 'z', team2:'y' ]]
def function = { 
    teams.inject( [:]) { result, team ->  
            result[team] = list.findAll { 
                team in [it.team1, it.team2] 
            }.size()
            result 
    }
}
println function()

```

Results the following output:

```
[x:1, y:2, z:1]

```

Now, trying to passing condition as closure to the `function` as below:

```
def function = { closure -> 
    teams.inject( [:]) { result, team ->
        result[team] = list.findAll(closure).size()
        result
    }
}

def t = { team in [it.team1, it.team2] }

println function(t)

```

But it says below error. `team` is available in the context though. 

> 
> Caught: groovy.lang.MissingPropertyException: No such property: team for class: testclosure
>  groovy.lang.MissingPropertyException: No such property: team for class: testclosure
>  at testclosure$\_run\_closure3.doCall(testclosure.groovy:8)
>  at testclosure$\_run\_closure2$\_closure6.doCall(testclosure.groovy:6)
>  at testclosure$\_run\_closure2.doCall(testclosure.groovy:6)
>  at testclosure.run(testclosure.groovy:12)
> 
> 
> 

Any pointers?