Shuffle the list in Scala

I have a question for a scala shuffle list 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 val color be random order val a, b, c and d .

+6
source share
1 answer

Scala user Random shuffle method method:

 scala.util.Random.shuffle(List(a,b,c,d)) 
+33
source

All Articles