Scala Templating no puede usar List[E]

@(magazinelist:List[models.Magazine])
@import utils._

This is what I'm trying to use, but it does not work. intelliJ tells List "the reference must be prefixed" and the second line also doesn't work (I copied from the Play documentation)

Pero si uso esto:

@(magazinelist:util.List[models.Magazine])
@import java.util

Although this will not cause an error, I am a bit confused. Is List not a datatype scala supports? Why do I have to use util.List to invoke it?? This looks kinda ugly. Also, if List is not supported so well, what datatype should I choose? Is there a preferable one?

preguntado el 12 de septiembre de 13 a las 03:09

Utilice las Seq en lugar de List. -

Do they work interchangeably? -

1 Respuestas

In Scala you have two types of List: java.util.List y List (from Scala's functionnal Collections). You should try to convert from one to another with .asScala (from scala.collection)

Respondido 24 ago 17, 13:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.