splat operator in groovy?
Posted
by IttayD
on Stack Overflow
See other posts from Stack Overflow
or by IttayD
Published on 2010-05-31T09:23:03Z
Indexed on
2010/05/31
10:12 UTC
Read the original article
Hit count: 274
def foo(map, name) {
println(map)
}
foo("bar", hi: "bye")
will print
[hi:bye]
Now I have a previous map that I wish to pass along to foo. In pseudo code, something like:
def otherMap = [hi: "world"]
foo("bar", hi: "bye", otherMap*)
So that it prints
[hi:world]
This doesn't work of course.
Also, trying to pass just the map mixes the order of arguments:
def otherMap = [hi: "world"]
foo("bar", otherMap)
will print
bar
How can I fix this?
© Stack Overflow or respective owner