Reputation: 797
How can I shuffle variable values like an array is shuffled?
Let's say a
, b
, c
, and d
are 1, 2, 3, and 4. I want the result to be [a, b, c, d].shuffle
. How can I do this? I've searched everywhere and can't get an answer.
Upvotes: 0
Views: 154
Reputation: 797
Nevermind, I found the answer, I can map variables like this; a, b = [1, 2]
, so I can also do a,b,c,d = [a,b,c,d].shuffle
to shuffle the array before mapping. Of course, if we are going for readability, we can do this;
shuffled = [a, b, c, d].shuffle
a, b, c, d = shuffled
Upvotes: 4