Skip to content

Better describe how groovy binding works #2

@samrocketman

Description

@samrocketman

If a variable has an undeclared type it goes into the script binding. The binding is visible to all methods which means data is shared.

evaluate() is a helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope.

In a variable binding, you can declare a closure which accepts no argument and must be restricted to calls without arguments.

With all of that in mind, here is your script working as intended.

evaluate ("test = { -> println \"Test is successful!\" }")
test()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions