Are Groovy closure signatures in global scope in Nextflow?

Say I have a Groovy function in a Nextflow script:

def foo() {
   def x = [1, 2]
   def inc = x.each{val -> val + 1}
   return inc
}

def bar() {
   def y = [1, 2]
   def dec = y.each{val -> val - 1}
   return dec   
}

workflow wf {
    main:
    foo()
    bar()
}

workflow {
    wf()
    wf()
}

Are the “val” variables as defined in the x.each and y.each closures in global scope, such that I potentially have to worry about them conflicting in this script?

In this example val is closure parameter, as such it’s only accessible in the closure scope.

Read more here

1 Like