lundi 20 avril 2015

Converting from Java List to Scala mutable Buffer

I'm having some issues converting from Scala to Java, and then back to Scala. I'm trying to convert from a Scala mutable buffer to a Java List, and then back to a Scala mutable buffer after I apply Java's nifty shuffling function.

I tried using Scala's Random library's shuffling function (even when the buffer is converted to a Scala list) however it's not working for me, as the type of buffer is of type "Card" which is an Object type that I have set up for the project that I am working on. The code in question looks like this:

def shuffleDeck() {
  val list: java.util.List[Card] = cards
  val newList = java.util.Collections.shuffle(list)

in the Scala IDE I'm using, the error given to me is:

type mismatch; found : Unit required: java.util.List[?]

I'm not really sure what to do. Any and all help would be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire