If I write
test = {
println("Hello world");
}
That creates a closure in a variable called test that I can invoke with test();
However
test: {
println("Hello world");
}
Immediately invokes the closure and I cannot invoke it with test();
What is the purpose of the second syntax?
That looks like a plain old labeled block of java code. Not Groovy closure syntax. Which would just allow you to scope the local variables within the block. If it is an alternative syntax I would avoid it.