Differences comparing to Java

  • By default, Groovy considers classes and methods public

Named params

https://docs.groovy-lang.org/latest/html/documentation/#_named_parameters_2

def foo(Map args) { 
  "${args.name}: ${args.age}" 
}
foo(name: 'Marie', age: 1)

def foo(Map args, Integer number) { 
  "${args.name}: ${args.age}, and the number is ${number}" 
} 
foo(name: 'Marie', age: 1, 23)
foo(23, name: 'Marie', age: 1) // with changed order