Breako Breako
Breako Breako

Reputation: 6461

Multiple assignments in groovy

In groovy I can do:

def (zip111, zip222, zip333) = ["111", "222", "333"];

But I can't do:

String (zip111, zip222, zip333) = ["111", "222", "333"];

Is there anyway I can multiply assign Strings?

Thanks

Upvotes: 2

Views: 3751

Answers (1)

tim_yates
tim_yates

Reputation: 171154

You need to do:

def (String zip111, String zip222, String zip333) = ["111", "222", "333"]

Or, pre-define your vars:

String zip111, zip222, zip333
(zip111, zip222, zip333) = ["111", 3, "333"]

Upvotes: 7

Related Questions