Question: How can I determine if a variable exists from within the Groovy code running in the Scripting Engine?

The variable was put by [ScriptEngine's put method](https://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html#put(java.lang.String,%20java.lang.Object))

Answer: 
```
// Example usage: defaultIfInexistent({myVar}, "default")
def defaultIfInexistent(varNameExpr, defaultValue) {
    try {
        varNameExpr()
    } catch (exc) {
        defaultValue
    }
}

```
You can check if the variable is exists by using 'contains' List method:

```
if (list.contains(var)) {
// your code
}

```