I make myself familiar with groovy and am a little surprised that the following code runs:
class Main {
static void main(String[] args) {
abc : 1
}
}
What is abc : 1
? I think it might be a map as the following code:
class Main {
static void main(String[] args) {
print(abc : 1)
}
}
leads to [abc:1]
being printed to the console, but
class Main {
static void main(String[] args) {
def map = abc : 1
}
}
compiles not!!! But the most confusing part is that wrapping the expression into a closure
class Main {
static void main(String[] args) {
def closure = {-> abc : 1}
print closure()
}
}
leads to 1
being printed to the console and not [abc:1]
. Is there any use of the colon I am not aware of?