akram akram - 1 month ago 12
Scala Question

Scala append Seq in with a string in a List Map or Foreach

I'm new to scala and i'm looking to append a

val adminEmailSeq = Seq.empty[String]
from a a List of object attribute.
My
List[User]
called 'admins'
Trying to do this doesn't work

admins.foreach(
admin => {
adminEmailSeq :+ admin.email
})


Although
admin.email
contains the right information,
adminEmailSeq.isEmpty
is always true.

Answer

For the description I assume that you need Emails from Admins

val adminEmailSeq = admins.map(_.email)
Comments