Defines a variable without specifying a type.
Syntax
def name = value
Description
With def, the type is inferred from the value, and the value can change later. You can also explicitly declare the type (int, double, String).
Example
def name = "Groovy" int score = 10 score = 20 println name println score
Expected output
Groovy 20
When to use?
General-purpose variable definition.