I have the below code using ListBuffer but I want to use immutable collection like List and achieve the same result
val list1: ListBuffer[String] = ListBuffer("a", "b", "c")
val s= list1
.foldLeft(mutable.ListBuffer.empty[String]) { (strings, content) =>
{
if(StringUtils.isNotBlank(content))
strings += content
else
strings += "-"
}
}
.mkString(";")
Second version
val list1: ListBuffer[String] = ListBuffer("a", "b", "c")
val s= list1
.foldLeft(mutable.ListBuffer.empty[String]) { (strings, content) =>
{
strings += content
}
}
.mkString(";")