Reputation: 2091
I created the following function to return two random integer values:
List<int> randomGenerator() {
return [(Random().nextInt(6) + 1),(Random().nextInt(6) + 1)];
}
And want to set to two program variables (left and right dice).
So tried by executing:
[rightDiceNumber,leftDiceNumber] = randomGenerator();
But it didn't work.
Upvotes: 1
Views: 215
Reputation: 4094
you can get your return value like this
List randomValues;
randomValues=randomGenerator();
print(randomValues[0]);
print(randomValues[1]);
Upvotes: 1