Scala for loop over two lists simultaneously
You could use zip: val ms: List[Message] = ??? val as: List[Author] = ??? var sms = for ( (m, a) <- (ms zip as)) yield new SmartMessage(m, a) If you don’t like for-comprehensions you could use map: var sms = (ms zip as).map{ case (m, a) => new SmartMessage(m, a)} Method zip creates collection … Read more