It won't work. It understands this as a getAt
method call on a foo
object:
foo["a", "b"]
and then the comma makes no sense.
You could use a varargs:
def foo(Map map, Object... args) { "$map $args" }
a = foo "a", "b", bar: {true}
println a // prints [bar:script_from_command_line$_run_closure1@1f3f7e0] [a, b]
Or reverse the param order:
def foo(Map map, args) { "$map $args" }
a = foo bar: {true}, ["a", "b"]
println a