Groovy expand tuple/map to arguments
Question: Is it possible to expand a map to a list of method arguments

In Python it is possible, eg. [Expanding tuples into
arguments](http://stackoverflow.com/questions/1993727/expanding-tuples-into-
arguments)

I have a `def map = ['a':1, 'b':2]` and a method `def m(a,b)`

I want to write smt like `m(*map)`


Answer: The [spread operator](http://mrhaki.blogspot.com.es/2009/09/groovy-goodness-
spread-operator.html) (*) is used to tear a list apart into single elements.
This can be used to invoke a method with multiple parameters and then spread a
list into the values for the parameters.

List (lists in Groovy are closest related with tuples in
Python[1](http://groovy.329449.n5.nabble.com/Why-has-groovy-no-built-in-tuple-
support-like-map-and-lists-
td360532.html),[2](http://stackoverflow.com/questions/626759/whats-the-
difference-between-list-and-tuples-in-python)):

    
    
    list = [1, 2]
    m(*list)
    

Map:

    
    
    map = [a: 1, b: 2]
    paramsList = map.values().toList()
    m(*paramsList)
    

An importan point is that you pass the arguments by position.

