title: How to append elements to list in a for loop : Scala
body: <p>i want to append list of elements to another list based on a condition. for example : find below code.</p>
  
  <pre><code>package test
  
  object main {
   def main(args: Array[String]): Unit ={
     val a = List(1,2,3,4,5)
     val b= List[Int]()
     for(x &lt;- a){
       if (x&gt;3){
         b:+x
       }
     }
     println(b)
   }
  }
  </code></pre>
  
  <p>when i execute this i am getting empty list.</p>