title: Scala Merge output lists into single list
body: <p>I have two lists</p>
  
  <pre><code>val list1 = List("customer1", "customer2")
  list1: List[String] = List(customer1, customer2)
  
  val list2 = List("John||32||Phone","Michael||34||Laptop")
  list2: List[String] = List(John||32||Phone, Michael||34||Laptop)
  </code></pre>
  
  <p>I'm trying to get output as below list</p>
  
  <pre><code>List((customer1,John),(customer1,32),(customer1,Phone),(customer2,Michael),(customer2,34),(customer2,Laptop))
  </code></pre>
  
  <p>Below is my code </p>
  
  <pre><code>val finalList = list1 zip list2
  finalList: List[(String, String)] = List((customer1,John||32||Phone), (customer2,Michael||34||Laptop))
  
  finalList.foreach{
          case (fieldName,fieldDetail) =&gt; {
            val cusList = fieldName + "-" + fieldDetail.replace("||",",")
            val cusDetailList = cusList.split("-") match {
              case Array(k, v) =&gt;
                v.split(",").map(value =&gt; (k, value)).toList
            }
            println(cusDetailList)
          }
  }
  </code></pre>
  
  <p>It prints as</p>
  
  <pre><code>List((customer1,John), (customer1,32), (customer1,Phone))
  List((customer2,Michael), (customer2,34), (customer2,Laptop))
  </code></pre>
  
  <p>I'm unable to get the output list as below</p>
  
  <pre><code>List((customer1,John),(customer1,32),(customer1,Phone),(customer2,Michael),(customer2,34),(customer2,Laptop))
  </code></pre>