I have a function with input params: Number and list of strings, e.g: (1, ListString)
And i need it to return a new list of strings that looks like:
[["1","name1"], ["1","name2"]] For each string in my input string list, i need to place it in that structure, so i've build the following:
def buildStringForproductsByCatView(tenantId:String, cat:List[String]):List[String]= { var tempList= List[String]()//(cat.foreach(x => "[[\"1\",\""+x+"\"]]")) cat.foreach(x => println(("[[\"1\",\""+x+"\"]]"))) cat.foreach(x => tempList + ("[[\"1\",\""+x+"\"]]")) println(tempList.mkString(",")) tempList } The list does not fill with items, i tried several ways, but could not get it.
The print line works fine, i am getting this:
[["1","1"]] [["1","cat1"]] I just want to add them to a new list of string..