I have a Seq
of objects like Seq(x1, x2, x3, x4)
and I want to tranform it to Seq(y1, y2, y3, y4)
What is the most efficient way of doing so
Right now I am
val seq1 = Seq(x1, x2, x3......)
var seq2 = Seq[MyType2]()
for (myObj <- seq1) {
seq2 = seq2 :+ myObj.tranformToType2
}
The problem is that the scala doc says
https://www.scala-lang.org/api/2.12.x/scala/collection/Seq.html
a new sequence consisting of all elements of this sequence followed by elem.
so I was wondering what is the most idiomatic/efficient way of tranforming a list of object to another list of object