title: Foreach vs Map in Scala
body: <p>i tried two ways for making a list  out of something</p>
  
  <pre><code>var response = List[RS_TxnNested]
  consumertxnlist.foreach(txData =&gt; {
    response = RS_TxnNested(blabla) +: response
  })
  </code></pre>
  
  <p>where consumertxnlist is a Seq[something] . </p>
  
  <p>Another way is</p>
  
  <pre><code>var response = consumerTxnList._2.map(txData =&gt; RS_TxnNested(blabla))
  </code></pre>
  
  <p>Can someone help me in clarifying which one is better and why?</p>