i have tow lists and i’m making shuffle to get a random element but when i combine the tow shuffle values i get this error :
This expression has a type of ‘void’ so its value can’t be used.
(Documentation) Try checking to see if you’re using the correct API;
there might be a function or call that returns void you didn’t expect.
Also check type parameters and variables which might also be void.
code:
final randomEmoji = emojis.shuffle();
final randomlLast = last.shuffle();
final finalText = randomlLast + randomEmoji;
2
Answers
fixed just call last.shuffle(); , don't assign it to a new variable
The shuffle method does not return a new list. It shuffles the original list in place and returns void hence the error you are getting.
If you want to get a random element from each list, you can do something like this:
If you just want to concantenate shuffled version of both list, do the below:
Where
finalList
is the combined shuffle list.