String localScope1 = 'localScope1'
def localScope2 = 'localScope2'
scriptScope = 'scriptScope'

println localScope1
println localScope2
println scriptScope

closure = {
    println localScope1
    println localScope2
    println scriptScope
}

def method() {
    try {localScope1} catch(MissingPropertyException e) {println 'localScope1NotAvailable' }
    try {localScope2} catch(MissingPropertyException e) {println 'localScope2NotAvailable' }
    println scriptScope
}

closure.call()
method()