Venusaur
unread,Mar 6, 2012, 9:41:40 PM3/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala-user
Hi. I'm new in scala.
After I learned about Random, I wanted to test methods of Random.
However, I couldn't understand why shuffle can accept List, but not
Array.
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Client VM, Java
1.7.0_02)
.
Type in expressions to have them evaluated.
Type :help for more information.
scala> util.Random.shuffle(List(1, 3, 5, 7, 9))
res0: List[Int] = List(3, 9, 5, 7, 1)
scala> util.Random.shuffle(Array(1, 3, 5, 7, 9))
<console>:8: error: inferred type arguments [Int,Array] do not conform
to method
shuffle's type parameter bounds [T,CC[X] <: TraversableOnce[X]]
util.Random.shuffle(Array(1, 3, 5, 7, 9))
^
scala>
Is there any workarounds for this?
Thanks in advance.