Reputation: 598
Based on this question I've coded the following which throws a compilation time error:
Here is the code:
43. Currency currency = new Currency()
44. (currency.rate_one, currency.time_one) = getDateAndRate()
My method with two return values:
def getDateAndRate(){
Date date = new Date()
double rate = getRate();
return [rate, date]
}
Error thrown
expecting '}', found ',' @ line 44, column 26.
(currency.rate_one, currency.time_one) = getDateAndRate()
^
Upvotes: 1
Views: 99
Reputation: 6508
There is a trick I learned only recently myself and that is to combine multiple assignment and with:
with (currency) {
(rate_one, time_one) = getDateAndTime()
}
Upvotes: 0
Reputation: 187399
Try this instead
def (rate, time) = getDateAndRate()
currency.rate_one = rate
currency.time_one = time
Upvotes: 2