Shuffle a List in Scala
15,083
User Scala's Random class method shuffle:
scala.util.Random.shuffle(List(a,b,c,d))
Author by
Deden Bangkit
I am an Indonesian citizen who currently works with documentary films, programming, and graphic design.
Updated on June 01, 2022Comments
-
Deden Bangkit almost 2 years
I have question to for shuffle list in scala using
scala.util.Random
.For example I have
val a = cyan val b = magenta val c = yellow val d = key val color = Random.shuffle.List(a,b,c,d).toString //but it doesn't work ;(
so I want the
val color
to be random order ofval a, b, c and d
.