what does * means in the groovy

View: New views
2 Messages — Rating Filter:   Alert me  

what does * means in the groovy

by samdallas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Following is the line used in one of test case.

    results = alarmDataService.getTabular(* multiple2, 0, 10)

What does * means, does it mean that next parameter should be considered as a variable.

Like in the above "multiple2" will be replaced by other variables.

Re: what does * means in the groovy

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's the "spread" operator.
You can spread a list of parameters.

def params = [1, 2]
def method(int i1, int i2) { println i1 + i2}
assert method(*params) == 3

On Wed, Oct 28, 2009 at 19:41, samdallas <samtekdallas@...> wrote:

>
> Following is the line used in one of test case.
>
>    results = alarmDataService.getTabular(* multiple2, 0, 10)
>
> What does * means, does it mean that next parameter should be considered as
> a variable.
>
> Like in the above "multiple2" will be replaced by other variables.
> --
> View this message in context: http://www.nabble.com/what-does-*-means-in-the-groovy-tp26099916p26099916.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email